Jenkins.getInstance() should be non-null

- It is never too late to do the right thing.
- The vast majority of usages of `Jenkins.getInstance()` in core currently assume that its return value is non-null
- This commit changes those that are written to correctly check for non-null values will call `Jenkins.getInstanceOrNull()`
- We deprecate the `Jenkins.getActiveInstance()` madness
- I checked with @kohsuke who said not to bother with a PR and just commit this strongly opinionated change direct to master as a PR will just degrade into a bikeshedding.
This commit is contained in:
Stephen Connolly committed 2016-03-07 22:08:36 +00:00
1 parent 7597c98a90
commit bb7c8fcedb
42 files changed
+99 -78

No files matched your search

+2 -2
View File
@@ -236,7 +236,7 @@ public class WebAppMain implements ServletContextListener {
} catch (Exception e) {
new HudsonFailedToLoad(e).publish(context,_home);
} finally {
Jenkins instance = Jenkins.getInstance();
Jenkins instance = Jenkins.getInstanceOrNull();
if(!success && instance!=null)
instance.cleanUp();
}
@@ -392,7 +392,7 @@ public class WebAppMain implements ServletContextListener {
public void contextDestroyed(ServletContextEvent event) {
terminated = true;
Jenkins instance = Jenkins.getInstance();
Jenkins instance = Jenkins.getInstanceOrNull();
if(instance!=null)
instance.cleanUp();
Thread t = initThread;