Bug 54769

Summary: Properties are not set correctly when reading from a file with prefix.
Product: Ant Reporter: Nicolas Cenerario <nicolas.cenerario>
Component: Core tasksAssignee: Ant Notifications List <notifications>
Status: RESOLVED FIXED    
Severity: normal CC: nicolas.cenerario
Priority: P2 Keywords: PatchAvailable
Version: 1.8.3   
Target Milestone: 1.9.4   
Hardware: PC   
OS: All   
Attachments: An archive containing testing files as long a a patch (which might be only partial)
Patch for the bug 54769: Setting properties one after another when reading from a file.

Description Nicolas Cenerario 2013-03-29 14:05:43 UTC
Created attachment 30119 [details]
An archive containing testing files as long a a patch (which might be only partial)

Inconsistency in property setting when using prefix.

1) create a property files containing properties that depends on each other like, for example:
a=A
b=${a}

2) Try to set property from this file with a prefix:
<project default="test">
	<target name="test">
		<property name="test.a" value="test.a" />
		<property file="build.properties" prefix="test" prefixValues="false" />
		<echo>test.a = ${test.a}</echo>
		<echo>test.b = ${test.b}</echo>
	</target>
</project>


3) The values are not what they should be. Here, test.b should be equals to ${a}. Here is the obtained output:
test:
     [echo] test.a = test.a
     [echo] test.b = A
Comment 1 Stefan Bodewig 2013-03-31 09:30:56 UTC
OK, both testcases fail in Jenkins, I'll add an option to completely turn of zip64 extensions and make turn it on in <jar> by default.
Comment 2 Stefan Bodewig 2013-03-31 11:04:40 UTC
(In reply to comment #1)
> OK, both testcases fail in Jenkins, I'll add an option to completely turn of
> zip64 extensions and make turn it on in <jar> by default.

sorry, this was meant to be a comment to bug 54762
Comment 3 Nicolas Cenerario 2013-04-02 15:00:49 UTC
Created attachment 30135 [details]
Patch for the bug 54769: Setting properties one after another when reading from a file.

I just saw that the two first lines from the patch included in the zip file should not be there.

I attach a new version of the patch.
I hope it helps: It is the first time I am participating to a open source project and I am not sure how to do it.

Thank you.
Comment 4 Stefan Bodewig 2014-01-01 12:13:36 UTC
First of all, Nicolas, I'm very sorry it took so long for anybody of the team to respond.

You haven't done anything wrong, the only thing you could have done was nagging us a more aggressive way.  Things tend to get forgotten when they pop up at a point in time when you cannot deal with them right away.

Nested property expansion in property files has been a sore point for quite a few releases, we have repeatedly broken it over the past few years as there are too many ways to get it wrong.  Your approach of resolving one property after the other won't work when prefixValues is true (or there is no prefix at all) and the iterator isn't returning keys in the order needed - you may end up with unexpanded properties because the property refered to in the value side hasn't been iterated over, yet.

should be fixed by svn revision 1554614