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

+1 -1
View File
@@ -1133,7 +1133,7 @@ public final class FilePath implements Serializable {
* @since 1.571
*/
public @CheckForNull Computer toComputer() {
Jenkins j = Jenkins.getInstance();
Jenkins j = Jenkins.getInstanceOrNull();
if (j != null) {
for (Computer c : j.getComputers()) {
if (getChannel()==c.getChannel()) {