You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by bo...@apache.org on 2005/05/04 11:21:59 UTC
cvs commit: ant/src/main/org/apache/tools/ant/types CommandlineJava.java Environment.java
bodewig 2005/05/04 02:21:59
Modified: src/main/org/apache/tools/ant/taskdefs ExecuteJava.java
src/main/org/apache/tools/ant/types CommandlineJava.java
Environment.java
Log:
Validate system properties before running a Java command, PR 34725
Revision Changes Path
1.51 +2 -0 ant/src/main/org/apache/tools/ant/taskdefs/ExecuteJava.java
Index: ExecuteJava.java
===================================================================
RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/ExecuteJava.java,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -r1.50 -r1.51
--- ExecuteJava.java 29 Mar 2005 20:39:00 -0000 1.50
+++ ExecuteJava.java 4 May 2005 09:21:59 -0000 1.51
@@ -179,6 +179,8 @@
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) {
1.69 +1 -0 ant/src/main/org/apache/tools/ant/types/CommandlineJava.java
Index: CommandlineJava.java
===================================================================
RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/types/CommandlineJava.java,v
retrieving revision 1.68
retrieving revision 1.69
diff -u -r1.68 -r1.69
--- CommandlineJava.java 7 Feb 2005 23:50:16 -0000 1.68
+++ CommandlineJava.java 4 May 2005 09:21:59 -0000 1.69
@@ -141,6 +141,7 @@
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);
1.20 +11 -3 ant/src/main/org/apache/tools/ant/types/Environment.java
Index: Environment.java
===================================================================
RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/types/Environment.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- Environment.java 30 Mar 2005 08:35:44 -0000 1.19
+++ Environment.java 4 May 2005 09:21:59 -0000 1.20
@@ -109,13 +109,21 @@
* @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();
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org