https://issues.apache.org/bugzilla/show_bug.cgi?id=55074
Bug ID: 55074
Summary: Inefficient
org.apache.tools.ant.property.LocalPropertyStack
implementation
Product: Ant
Version: 1.8.4
Hardware: All
OS: All
Status: NEW
Severity: major
Priority: P2
Component: Core
Assignee: [email protected]
Reporter: [email protected]
I've tried to use Ant build with <parallel> tasks like this (see below) to
imitate High Load for the system:
<target name="load-test">
<parallel>
<antcall target="my-test"/>
</parallel>
<parallel>
<antcall target="my-test"/>
</parallel>
<parallel>
<antcall target="my-test"/>
</parallel>
...
...
...
<parallel>
<antcall target="my-test"/>
</parallel>
</target>
After running this build I sometimes caught an exception:
Caused by: java.util.ConcurrentModificationException
at java.util.LinkedList$ListItr.checkForComodification(LinkedList.java:761)
at java.util.LinkedList$ListItr.next(LinkedList.java:696)
at
org.apache.tools.ant.property.LocalPropertyStack.evaluate(LocalPropertyStack.java:96)
at
org.apache.tools.ant.property.LocalProperties.evaluate(LocalProperties.java:124)
at org.apache.tools.ant.PropertyHelper.getProperty(PropertyHelper.java:845)
at org.apache.tools.ant.Project.getProperty(Project.java:607)
at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:374)
at org.apache.tools.ant.taskdefs.CallTarget.execute(CallTarget.java:105)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
... 32 more
The problem is that <antcall> task delegates it call to <ant> task
(org.apache.tools.ant.taskdefs.Ant) which has such code in line 374 of its
execute method:
String thisAntFile = getProject().getProperty(MagicNames.ANT_FILE);
PropertyHelper uses LocalProperties which by turn uses LocalPropertyStack
resolve "MagicNames.ANT_FILE" property. The origin of the problem is that
LocalPropertyStack uses LinkedList (which is not thread safe) to hold all the
properties.
The simplest solution is to use Collections.synchronizedList(new
LinkedList<Object>()) instead of LinkedList
--
You are receiving this mail because:
You are the assignee for the bug.