ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject DO NOT REPLY [Bug 48299] New: ConcurrentModificationException with <parallel> and <scriptcondition> tasks
Date Fri, 27 Nov 2009 15:38:27 GMT

           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

I have a build system where sometime a ConcurrentModificationException is

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 .
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:
------- You are receiving this mail because: -------
You are the assignee for the bug.

View raw message