diff --git a/core/src/main/java/hudson/EnvVars.java b/core/src/main/java/hudson/EnvVars.java index 071eb98d28..6204386c51 100644 --- a/core/src/main/java/hudson/EnvVars.java +++ b/core/src/main/java/hudson/EnvVars.java @@ -156,6 +156,12 @@ public class EnvVars extends TreeMap { 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. diff --git a/maven-plugin/src/main/java/hudson/maven/MavenBuilder.java b/maven-plugin/src/main/java/hudson/maven/MavenBuilder.java index d8c5a59567..13cc78a54b 100644 --- a/maven-plugin/src/main/java/hudson/maven/MavenBuilder.java +++ b/maven-plugin/src/main/java/hudson/maven/MavenBuilder.java @@ -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 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()]));