From 5d167c2f4703ef857c043bcab9d7c57b0b1d0fcf Mon Sep 17 00:00:00 2001 From: Jaikiran Pai Date: Thu, 1 Mar 2018 16:45:56 +0530 Subject: [PATCH] BZ-62147 Fix the Java 8 refactoring regression which resulted in property value replacement for StringResource within a Token --- .../apache/tools/ant/types/resources/Tokens.java | 7 ++++++- .../antunit/types/resources/tokens-test.xml | 16 ++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) 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} + + + + + + + + +