Currently, the jenkins.model.Jenkins::getInstance() method is marked as @CheckForNull, but the most of Jenkins code does not actually check the return value. It leads to tons of static analysis errors, hence it is hard to analyze the code.
I propose to...
- Add an additional method (e.g. Jenkins::getActiveInstance()), which throws an exception on access errors
- Convert all non-checked Jenkins::getInstance() methods
Code changed in jenkins
User: Oleg Nenashev
Path:
core/src/main/java/hudson/model/Hudson.java
core/src/main/java/jenkins/model/Jenkins.java
http://jenkins-ci.org/commit/jenkins/e6c2e16f7a1e2487a1d201aa11ae0c44e75a6ad7
Log:
[FIXED JENKINS-23339] - Introduce the validated Jenkins::getActiveInstance() method
jenkins.model.Jenkins::getInstance() method is marked as @CheckForNull, but the most of Jenkins code does not actually check the return value. It leads to tons of static analysis errors, hence it is hard to analyze the code.
The change also adds annotations to old methods like Hudson::getInstance()
Signed-off-by: Oleg Nenashev <o.v.nenashev@gmail.com>