You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bu...@apache.org on 2009/11/09 18:10:16 UTC

DO NOT REPLY [Bug 41602] Ant jython attributes are not thread-safe

https://issues.apache.org/bugzilla/show_bug.cgi?id=41602

--- Comment #4 from valentino miazzo <va...@miazzo.net> 2009-11-09 09:10:14 UTC ---
This bug affects also Javascript.

ANT script:
-----------

<target name="t13">
    <parallel failonany='false'>
        <t13.sd key="one" />
        <t13.sd key="two" />
        <t13.sd key="three" />
        <t13.sd key="four" />
    </parallel>
</target>

<scriptdef name="t13.sd" language="javascript">
    <attribute name="key" />
    <![CDATA[
    var key = attributes.get("key");
    project.log("threadtest called with key: " + key);
    ]]>
</scriptdef>

Results:
--------

threadtest called with key: four
threadtest called with key: four
threadtest called with key: two
threadtest called with key: three

Comment on results:
-------------------

You can see that execution 'four' of t13.sd overwrites the key parameter of
execution 'one'.

Cause:
------

Each ScriptDef object as a single ScriptRunnerBase object. This runner is used
by any ScriptDefBase pointing to the ScriptDef.
When the same 'scripdef-ined' task is used inside a parallel task,  it creates
a race condition where beans of a ScriptDefBase overwrites the beans of another
ScriptDefBase .

Fix:
----

I'm not an expert of the ANT codebase, so I cannot suggest a proper fix.
Anyway I have a quick an dirty patch that seems to fix the problem.

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