https://issues.apache.org/bugzilla/show_bug.cgi?id=48310
Summary: ConcurrentModificationException with <parallel> and
<scriptcondition> tasks
Product: Ant
Version: 1.7.1
Platform: PC
OS/Version: Windows XP
Status: NEW
Severity: major
Priority: P2
Component: Core
AssignedTo: [email protected]
ReportedBy: [email protected]
This was originally bug 48299 but was lost in issues.a.o data loss on
2009-11-26/27 and re-created from the archives.
I have a build system where sometime a ConcurrentModificationException is
thrown.
The system is quite complex and I'm not able to produce a recipe for the bug.
Anyway, I looked at the ANT source code and found the (possible) causes.
Method void Project.addReference(String,Object) modifies Hashtable
Projet.references .
Method Hashtable Project.getReferences() returns references.
This implementation exposes to ConcurrentModificationException when Thread A
calls addReference() and Thread B iterates over getReferences().
Even if dictionary.keySet().iterator()
This actually happens to me when using <parallel> and <scriptcondition> tasks.
In this case, when scripcondition task is executed, the method void
ScriptRunnerBase.bindToComponent(ProjectComponent) invokes
Project.getReferences(), then obtains a iterator with Map.keySet().iterator()
to fill script beans.
In another thread some task modifies calls Project.addReference() and therefore
a ConcurrentModificationException is threw.
Another problematic scenario is this.
Method void Project.addOrReplaceTarget(String,Target) modifies Hashtable
Projet.target .
Method Hashtable Project.getTargets() returns targets.
This implementation exposes to race conditions when Thread A calls
addOrReplaceTarget() and Thread B calls getTargets().
I think a copy of those collection should be returned instead of the live ones.
I tried to produce a patch but I'm not sure off all the implication of those
changes (Javadocs state that these methods return live collections), so I leave
this to the maintainers.
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.