diff --git a/src/main/org/apache/tools/ant/taskdefs/ExecuteJava.java b/src/main/org/apache/tools/ant/taskdefs/ExecuteJava.java index 0bf852c20..d5e9b9fb6 100644 --- a/src/main/org/apache/tools/ant/taskdefs/ExecuteJava.java +++ b/src/main/org/apache/tools/ant/taskdefs/ExecuteJava.java @@ -179,6 +179,8 @@ public class ExecuteJava implements Runnable, TimeoutObserver { throw new BuildException("Could not find " + classname + "." + " Make sure you have it in your" + " classpath"); + } catch (BuildException e) { + throw e; } catch (SecurityException e) { throw e; } catch (ThreadDeath e) { diff --git a/src/main/org/apache/tools/ant/types/CommandlineJava.java b/src/main/org/apache/tools/ant/types/CommandlineJava.java index fa69fc27d..8d1524161 100644 --- a/src/main/org/apache/tools/ant/types/CommandlineJava.java +++ b/src/main/org/apache/tools/ant/types/CommandlineJava.java @@ -141,6 +141,7 @@ public class CommandlineJava implements Cloneable { p.putAll(mergePropertySets()); for (Enumeration e = variables.elements(); e.hasMoreElements();) { Environment.Variable v = (Environment.Variable) e.nextElement(); + v.validate(); p.put(v.getKey(), v.getValue()); } System.setProperties(p); diff --git a/src/main/org/apache/tools/ant/types/Environment.java b/src/main/org/apache/tools/ant/types/Environment.java index ea1999aac..494511fbd 100644 --- a/src/main/org/apache/tools/ant/types/Environment.java +++ b/src/main/org/apache/tools/ant/types/Environment.java @@ -109,13 +109,21 @@ public class Environment { * @throws BuildException if key or value are unassigned */ public String getContent() throws BuildException { + validate(); + StringBuffer sb = new StringBuffer(key.trim()); + sb.append("=").append(value.trim()); + return sb.toString(); + } + + /** + * checks whether all required attributes have been specified. + * @throws BuildException if key or value are unassigned + */ + public void validate() { if (key == null || value == null) { throw new BuildException("key and value must be specified " + "for environment variables."); } - StringBuffer sb = new StringBuffer(key.trim()); - sb.append("=").append(value.trim()); - return sb.toString(); } }