Merge remote-tracking branch 'origin/2.0' into symbol

Conflicts:
	core/src/main/java/jenkins/slaves/JnlpSlaveAgentProtocol.java
	core/src/main/java/jenkins/slaves/JnlpSlaveAgentProtocol2.java
This commit is contained in:
Kohsuke Kawaguchi committed 2016-03-22 10:47:20 -07:00
commit 90ff340210
147 files changed
+3598 -1393

No files matched your search

@@ -47,7 +47,9 @@ import java.net.URLConnection;
import java.util.Collections;
import java.util.List;
import java.util.regex.Pattern;
import javax.annotation.CheckForNull;
import jenkins.model.Jenkins;
import jenkins.util.JenkinsJVM;
import org.apache.commons.httpclient.Credentials;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.UsernamePasswordCredentials;
@@ -216,8 +218,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 agents
ProxyConfiguration p = h!=null ? h.proxy : null;
final ProxyConfiguration p = get();
if(p==null)
return url.openConnection();
@@ -228,22 +229,21 @@ public final class ProxyConfiguration extends AbstractDescribableImpl<ProxyConfi
@Override
public PasswordAuthentication getPasswordAuthentication() {
if (getRequestorType()!=RequestorType.PROXY) return null;
ProxyConfiguration p = Jenkins.getInstance().proxy;
return new PasswordAuthentication(p.getUserName(),
p.getPassword().toCharArray());
}
});
}
for (URLConnectionDecorator d : URLConnectionDecorator.all())
d.decorate(con);
if (JenkinsJVM.isJenkinsJVM()) { // this code may run on a slave
decorate(con);
}
return con;
}
public static InputStream getInputStream(URL url) throws IOException {
Jenkins h = Jenkins.getInstance(); // this code might run on agents
final ProxyConfiguration p = (h != null) ? h.proxy : null;
final ProxyConfiguration p = get();
if (p == null)
return new RetryableHttpStream(url);
@@ -265,6 +265,27 @@ public final class ProxyConfiguration extends AbstractDescribableImpl<ProxyConfi
return is;
}
@CheckForNull
private static ProxyConfiguration get() {
if (JenkinsJVM.isJenkinsJVM()) {
return _get();
}
return null;
}
@CheckForNull
private static ProxyConfiguration _get() {
JenkinsJVM.checkJenkinsJVM();
// this code could be called between the JVM flag being set and theInstance initialized
Jenkins jenkins = Jenkins.getInstance();
return jenkins == null ? null : jenkins.proxy;
}
private static void decorate(URLConnection con) throws IOException {
for (URLConnectionDecorator d : URLConnectionDecorator.all())
d.decorate(con);
}
private static final XStream XSTREAM = new XStream2();
private static final long serialVersionUID = 1L;