You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Hille <dh...@gmx.de> on 2010/07/10 18:24:10 UTC

Strange "toString"-behaviour on string resources

Running the following build file against ant 1.7.1


<project default="ant-test">
   <target name="ant-test" >
     <resources id="A">
         <string value="a"/>
         <string value="b"/>
     </resources>
     <union id="union"><resources refid="A"/></union>
     <echo>
       A:     ${toString:A}           = a;b
       union: ${toString:union}           = a;b
       A:     ${toString:A}           = a;b
     </echo>
   </target>
</project>



I'd exspect s.th. along the lines of


ant-test:
      [echo]
      [echo]       A:     a;b           = a;b
      [echo]       union: a;b           = a;b
      [echo]       A:     a;b           = a;b
      [echo]



however I got (note the missing "a;b" after the first "A:")


ant-test:
      [echo]
      [echo]       A:                = a;b
      [echo]       union: a;b           = a;b
      [echo]       A:     a;b           = a;b
      [echo]


This happens on Win2K running the binary dist of ant 1.7.1 or 1.8.1 
(both show the above result).

I do not think this is an ant bug, but rather me misunderstanding some 
ant concepts. Just in case, I didi search the bug database for 
"toString" without getting an appropriate hit.

Can somebody tell me why my expectations are incorrect, please?

Hille.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: Strange "toString"-behaviour on string resources

Posted by Stefan Bodewig <bo...@apache.org>.
On 2010-07-12, Hille wrote:

> Thanks a lot for taking the time to answer. I filed the bug report

> https://issues.apache.org/bugzilla/show_bug.cgi?id=49588

Thanks, fixed in svn by now.

> being a bit unsure about whether to post Your additional info. Please
> feel free to add any missing useful pieces.

I've added a link to one of the several mailing list archives as URL to
the issue.

Cheers

        Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: Strange "toString"-behaviour on string resources

Posted by Hille <dh...@gmx.de>.
Thanks a lot for taking the time to answer. I filed the bug report

https://issues.apache.org/bugzilla/show_bug.cgi?id=49588

being a bit unsure about whether to post Your additional info. Please 
feel free to add any missing useful pieces.

Hille


Stefan Bodewig schrieb:
> [...]
> 
> No, you've really found a bug.  The <resources> resource collection
> lazily caches its contents when iterating over the nested resources and
> ensures it does so properly for the "normal" resource collection
> contract.
> 
> The toString method in Resources does not ensure it builds up a new
> cache when needed.  Your first invocation gets the results of an empty
> cache, the union internally iterates over the collection and fills the
> cache which is then used by your second invocation.
> 
> If you could find the time to open a bugzilla issue for it, that would
> be great.  Otherwise I'll do so myself sometime during the rest of the
> week - it will be fixed for Ant 1.8.2.
> 
> Stefan


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: Strange "toString"-behaviour on string resources

Posted by Stefan Bodewig <bo...@apache.org>.
On 2010-07-10, Hille wrote:

> Running the following build file against ant 1.7.1

> <project default="ant-test">
>   <target name="ant-test" >
>     <resources id="A">
>         <string value="a"/>
>         <string value="b"/>
>     </resources>
>     <union id="union"><resources refid="A"/></union>
>     <echo>
>       A:     ${toString:A}           = a;b
>       union: ${toString:union}           = a;b
>       A:     ${toString:A}           = a;b
>     </echo>
>   </target>
> </project>

> however I got (note the missing "a;b" after the first "A:")

> ant-test:
>      [echo]
>      [echo]       A:                = a;b
>      [echo]       union: a;b           = a;b
>      [echo]       A:     a;b           = a;b
>      [echo]


> I do not think this is an ant bug, but rather me misunderstanding some
> ant concepts.

No, you've really found a bug.  The <resources> resource collection
lazily caches its contents when iterating over the nested resources and
ensures it does so properly for the "normal" resource collection
contract.

The toString method in Resources does not ensure it builds up a new
cache when needed.  Your first invocation gets the results of an empty
cache, the union internally iterates over the collection and fills the
cache which is then used by your second invocation.

If you could find the time to open a bugzilla issue for it, that would
be great.  Otherwise I'll do so myself sometime during the rest of the
week - it will be fixed for Ant 1.8.2.

Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org