This is a fix for bug# 3390 (depends list, trailing ","). It involves two
classes:
org.apache.tools.ant.Target
org.apache.tools.and.ProjectHelper
The fix itself is just a verification that tokens added to the dependency
list are not empty strings. However, this logic exists in two places
(Target and ProjectHelper). The patch refactors this and makes
Target.addDependency() private, so that modifications to the list all go
through Target.setDepends().
Here are the two diff files:
--- Target.java.save Mon Sep 03 21:48:24 2001
+++ Target.java Sat Sep 22 22:08:59 2001
@@ -85,7 +85,10 @@
StringTokenizer tok =
new StringTokenizer(depS, ",", false);
while (tok.hasMoreTokens()) {
- addDependency(tok.nextToken().trim());
+ String token = tok.nextToken().trim();
+ if (!token.equals("")) {
+ addDependency(token);
+ }
}
}
}
@@ -126,7 +129,7 @@
return retval;
}
- public void addDependency(String dependency) {
+ private void addDependency(String dependency) {
dependencies.addElement(dependency);
}
--- ProjectHelper.java.save Mon Sep 03 21:48:24 2001
+++ ProjectHelper.java Sat Sep 22 22:07:29 2001
@@ -421,11 +421,7 @@
// take care of dependencies
if (depends.length() > 0) {
- StringTokenizer tok =
- new StringTokenizer(depends, ",", false);
- while (tok.hasMoreTokens()) {
- target.addDependency(tok.nextToken().trim());
- }
+ target.setDepends(depends);
}
}