ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 48299] New: ConcurrentModificationException with <parallel> and <scriptcondition> tasks
Date Fri, 27 Nov 2009 15:38:27 GMT
https://issues.apache.org/bugzilla/show_bug.cgi?id=48299

           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: notifications@ant.apache.org
        ReportedBy: valentino@miazzo.net


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.

Thanks,
Valentino

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

Mime
View raw message