Fixed NPE when trying to reset the proxy setting in the update center.

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@10025 71c3de6d-444a-0410-be80-ed276b4c234a
This commit is contained in:
kohsuke committed 2008-06-11 19:08:23 +00:00
1 parent bb6aba8a8b
commit 61e79bf4bf
1 file changed
+8 -4
+8 -4
View File
@@ -11,8 +11,6 @@ import javax.servlet.ServletException;
import java.io.File;
import java.io.FilenameFilter;
import java.io.IOException;
import java.io.StringWriter;
import java.io.PrintWriter;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collection;
@@ -173,11 +171,17 @@ public final class PluginManager extends AbstractModelObject {
}
public void doProxyConfigure(@QueryParameter("proxy.server") String server, @QueryParameter("proxy.port") String port, StaplerResponse rsp) throws IOException {
System.setProperty("http.proxyHost",Util.fixEmptyAndTrim(server));
System.setProperty("http.proxyPort",Util.fixEmptyAndTrim(port));
setProp("http.proxyHost", Util.fixEmptyAndTrim(server));
setProp("http.proxyPort",Util.fixEmptyAndTrim(port));
rsp.sendRedirect("./advanced");
}
private void setProp(String key, String value) {
// System.setProperty causes NPE if t he value is null.
if(value==null) System.getProperties().remove(key);
else System.setProperty(key,value);
}
private final class UberClassLoader extends ClassLoader {
public UberClassLoader() {
super(PluginManager.class.getClassLoader());