mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-10 02:26:18 +00:00
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:
1 parent
7597c98a90
commit
bb7c8fcedb
42 files changed
+99
-78
No files matched your search
@@ -215,7 +215,7 @@ public final class ProxyConfiguration extends AbstractDescribableImpl<ProxyConfi
|
||||
* This method should be used wherever {@link URL#openConnection()} to internet URLs is invoked directly.
|
||||
*/
|
||||
public static URLConnection open(URL url) throws IOException {
|
||||
Jenkins h = Jenkins.getInstance(); // this code might run on slaves
|
||||
Jenkins h = Jenkins.getInstanceOrNull(); // this code might run on slaves
|
||||
ProxyConfiguration p = h!=null ? h.proxy : null;
|
||||
if(p==null)
|
||||
return url.openConnection();
|
||||
@@ -241,7 +241,7 @@ public final class ProxyConfiguration extends AbstractDescribableImpl<ProxyConfi
|
||||
}
|
||||
|
||||
public static InputStream getInputStream(URL url) throws IOException {
|
||||
Jenkins h = Jenkins.getInstance(); // this code might run on slaves
|
||||
Jenkins h = Jenkins.getInstanceOrNull(); // this code might run on slaves
|
||||
final ProxyConfiguration p = (h != null) ? h.proxy : null;
|
||||
if (p == null)
|
||||
return new RetryableHttpStream(url);
|
||||
|
||||
Reference in new issue
Block a user