https://issues.apache.org/bugzilla/show_bug.cgi?id=55074
--- Comment #2 from Gan Dong <[email protected]> --- I investigated into this problem in our user's environment, and found that it was using Ant-contrib's "forget" task (http://ant-contrib.sourceforge.net/tasks/tasks/forget.html). The task simply created a child thread of main ant thread, and using this new thread to run nested ant tasks in background. I think this might be the cause. Below are my observation, can you please review and see if it makes sense. While "parallel" task provided by ant always makes a new copy of LocalPropertyStack for the child thread when it enters the run() method, the ant-contrib "forget" task does not do that. It simply creates a new thread and perform the task using the thread. ==== from Parallel.java ==== public void run() { try { LocalProperties.get(getProject()).copy(); .... ==== from ForgetTask.java ==== public void execute() { Thread t = new Thread(this); t.setDaemon(daemon); t.start(); } public void run() { super.execute(); } On the other hand, LocalProperties is an InheritableThreadLocal, which means the parent thread and child threads are sharing the same LocalPropertyTask. In this case, the child thread that runs nested tasks is the child of the main Ant thread, thus it actually has the same LocalThreadStack as main ant thread. So this leads to the concurrent issue between main ant thread and child forget tasks thread, or between different child threads of "forget" tasks. I also wrote below reproducer to verify above thought. <target name="run-forget"> <forget> <antcall target="job1" /> </forget> <forget> <antcall target="job2" > <param name="dummy" value="foo" /> </antcall> </forget> </target> <target name="job1"> <property name="dummy" value="job1" /> <echo message="JOB1: dummy=${dummy}" /> <sleep seconds="1" /> </target> <target name="job2"> <property name="dummy" value="job2" /> <echo message="JOB2: dummy=${dummy}" /> </target> When I call above "run-forget" task in a couple times, I get various of exceptions quite often. But when I use <parallel> to simulate above, I don't get any problem. So it seems that "forget" usage was the cause. I guess this task was wrote before LocalProperties was introduced, and hadn't been updated since then. -- You are receiving this mail because: You are the assignee for the bug.
