提交 ad7b504c 编写于 作者: K kohsuke

user report indicates that if someone puts a null value into a system proeprty...

user report indicates that if someone puts a null value into a system proeprty we get a hard-to-diagnose NPE. Adding code to proactively watch out for that:

[workspace] $ /usr/lib/jvm/sun-jdk-1.6/bin/java -cp /opt/glassfish/.hudson/plugins/maven-plugin/WEB-INF/lib/maven-agent-1.355.jar:/usr/share/maven-bin-2.1/boot/classworlds-1.1.jar hudson.maven.agent.Main /usr/share/maven-bin-2.1 /opt/glassfish/server/glassfish/domains/domain1/applications/hudson/WEB-INF/lib/remoting-1.355.jar /opt/glassfish/.hudson/plugins/maven-plugin/WEB-INF/lib/maven-interceptor-1.355.jar 35855 /opt/glassfish/.hudson/plugins/maven-plugin/WEB-INF/lib/maven2.1-interceptor-1.2.jar
<===[HUDSON REMOTING CAPACITY]===>���channel started
channel stopped
ERROR: Processing failed due to a bug in the code. Please report this to users@hudson.dev.java.net
java.lang.NullPointerException
	at java.util.Hashtable.put(Hashtable.java:394)
	at java.util.Hashtable.putAll(Hashtable.java:466)
	at hudson.maven.MavenBuilder.call(MavenBuilder.java:156)
	at hudson.maven.MavenModuleSetBuild$Builder.call(MavenModuleSetBuild.java:696)
	at hudson.maven.MavenModuleSetBuild$Builder.call(MavenModuleSetBuild.java:640)
	at hudson.remoting.UserRequest.perform(UserRequest.java:114)
	at hudson.remoting.UserRequest.perform(UserRequest.java:48)
	at hudson.remoting.Request$2.run(Request.java:270)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
	at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
	at java.util.concurrent.FutureTask.run(FutureTask.java:138)
	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
	at java.lang.Thread.run(Thread.java:619)
project=hudson.maven.MavenModuleSet@19cc863[Meetspace]
project.getModules()=[hudson.maven.MavenModule@19fef64[Meetspace/com.steeplesoft:meetspace], hudson.maven.MavenModule@bc2f14[Meetspace/com.steeplesoft.meetspace:meetspace-parent], hudson.maven.MavenModule@11d8f11[Meetspace/com.steeplesoft.meetspace:plugin-engine], hudson.maven.MavenModule@b6e204[Meetspace/com.steeplesoft.meetspace:webapp], hudson.maven.MavenModule@b097da[Meetspace/com.steeplesoft.meetspace.plugins:helloworld-plugin], hudson.maven.MavenModule@1c18b6a[Meetspace/com.steeplesoft.meetspace.plugins:plugin-api], hudson.maven.MavenModule@1a80928[Meetspace/com.steeplesoft.meetspace.plugins:plugin-engine]]
project.getRootModule()=hudson.maven.MavenModule@bc2f14[Meetspace/com.steeplesoft.meetspace:meetspace-parent]
FATAL: null
java.lang.NullPointerException
	at java.util.Hashtable.put(Hashtable.java:394)
	at java.util.Hashtable.putAll(Hashtable.java:466)
	at hudson.maven.MavenBuilder.call(MavenBuilder.java:156)
	at hudson.maven.MavenModuleSetBuild$Builder.call(MavenModuleSetBuild.java:696)
	at hudson.maven.MavenModuleSetBuild$Builder.call(MavenModuleSetBuild.java:640)
	at hudson.remoting.UserRequest.perform(UserRequest.java:114)
	at hudson.remoting.UserRequest.perform(UserRequest.java:48)
	at hudson.remoting.Request$2.run(Request.java:270)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
	at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
	at java.util.concurrent.FutureTask.run(FutureTask.java:138)
	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
	at java.lang.Thread.run(Thread.java:619)

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@30326 71c3de6d-444a-0410-be80-ed276b4c234a
上级 92c68fbc
......@@ -156,6 +156,12 @@ public class EnvVars extends TreeMap<String,String> {
entry.setValue(Util.replaceMacro(entry.getValue(), env));
}
}
@Override
public String put(String key, String value) {
if (value==null) throw new IllegalArgumentException("Null value not allowed as an environment variable: "+key);
return super.put(key,value);
}
/**
* Takes a string that looks like "a=b" and adds that to this map.
......
......@@ -54,6 +54,7 @@ import org.codehaus.plexus.configuration.PlexusConfiguration;
import java.io.IOException;
import java.io.PrintStream;
import java.lang.reflect.InvocationTargetException;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
import java.util.ArrayList;
......@@ -153,7 +154,12 @@ public abstract class MavenBuilder implements DelegatingCallable<Result,IOExcept
markAsSuccess = false;
System.getProperties().putAll(systemProps);
// working around NPE when someone puts a null value into systemProps.
for (Map.Entry<String,String> e : systemProps.entrySet()) {
if (e.getValue()==null)
throw new IllegalArgumentException("System property "+e.getKey()+" has a null value");
System.getProperties().put(e.getKey(), e.getValue());
}
listener.getLogger().println(formatArgs(goals));
int r = Main.launch(goals.toArray(new String[goals.size()]));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册