diff --git a/src/main/org/apache/tools/ant/types/resources/Tokens.java b/src/main/org/apache/tools/ant/types/resources/Tokens.java index c8e911090..edf07432d 100644 --- a/src/main/org/apache/tools/ant/types/resources/Tokens.java +++ b/src/main/org/apache/tools/ant/types/resources/Tokens.java @@ -65,7 +65,12 @@ public class Tokens extends BaseResourceCollectionWrapper { List result = new ArrayList<>(); for (String s = tokenizer.getToken(rdr); s != null; s = tokenizer.getToken(rdr)) { - StringResource resource = new StringResource(getProject(), s); + // do not send the Project to the constructor of StringResource, since + // the semantics of that constructor clearly state that property value + // replacement takes place on the passed string value. We don't want + // that to happen. + final StringResource resource = new StringResource(s); + resource.setProject(getProject()); result.add(resource); } return result; diff --git a/src/tests/antunit/types/resources/tokens-test.xml b/src/tests/antunit/types/resources/tokens-test.xml index c09d604cb..26a300d4c 100644 --- a/src/tests/antunit/types/resources/tokens-test.xml +++ b/src/tests/antunit/types/resources/tokens-test.xml @@ -44,6 +44,22 @@ + + + + + + + one two three $${bz-62147-four} $${bz-62417-nonexistent-prop} + + + + + + + + +