You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Arun Katkere <ka...@praja.com> on 2000/08/03 02:39:54 UTC

[BUG] infinite loop with empty properties file

This bug didn't exist before (I have had an empty .ant.properties file in my
home directory for a while). With Ant 1.1, ant goes into an infinite loop if
it encounters an empty properties file. To reproduce:

foo.properties (empty):


test.xml:
<project name="test" default="main" basedir=".">
<target name="main">
  <property file=".foo"/>
</target>
</project>

Run ant on test.xml.

Looking at the code, Property.resolveProperties has a loop while(more) and
when there are no properties, more is never false since you never enter the
inner while. Seems like just a check for props.size() == 0 at the begining
will do, but not knowing what resolveProperties does I don't know if it
handles all cases. (Outer loop has no purpose since you can't break out of
inner loop until the enumeration is empty. After the inner loop runs once,
if "more" is still true, how would "more" ever become false? Seems like e =
props.keys() should move inside the loop. Even if you do that, as a rule I
hate any code that goes into an infinite loop upon bad input. What if the
properties is such that everything can never be completely resolved?
Shouldn't we signal an error instead of looping forever trying to resolve
it?)

-arun