Here is the stack trace of the exception

java.util.ConcurrentModificationException.
Please check the build log for more details.
         at org.apache.tools.ant.taskdefs.Exit.execute(Exit.java:162)
         at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
         at sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)
         at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
         at java.lang.reflect.Method.invoke(Method.java:498)
         at 
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:99)
         at org.apache.tools.ant.Task.perform(Task.java:350)
         at org.apache.tools.ant.Target.execute(Target.java:449)
         at org.apache.tools.ant.Target.performTasks(Target.java:470)
         at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1391)
         at 
org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:36)
         at org.apache.tools.ant.Project.executeTargets(Project.java:1254)
         at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:437)
         at 
org.apache.tools.ant.taskdefs.CallTarget.execute(CallTarget.java:106)
         at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
         at sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)
         at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
         at java.lang.reflect.Method.invoke(Method.java:498)
         at 
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:99)
         at org.apache.tools.ant.Task.perform(Task.java:350)
         at java.util.Vector.forEach(Vector.java:1275)
         at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:67)
         at 
net.sf.antcontrib.logic.TryCatchTask$CatchBlock.execute(TryCatchTask.java:138)
         at net.sf.antcontrib.logic.TryCatchTask.execute(TryCatchTask.java:224)
         at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
         at sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)
         at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
         at java.lang.reflect.Method.invoke(Method.java:498)
         at 
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:99)
         at org.apache.tools.ant.Task.perform(Task.java:350)
         at org.apache.tools.ant.Target.execute(Target.java:449)
         at org.apache.tools.ant.Target.performTasks(Target.java:470)
         at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1391)
         at org.apache.tools.ant.Project.executeTarget(Project.java:1364)
         at 
org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
         at org.apache.tools.ant.Project.executeTargets(Project.java:1254)
         at org.apache.tools.ant.Main.runBuild(Main.java:830)
         at org.apache.tools.ant.Main.startAnt(Main.java:223)
         at org.apache.tools.ant.launch.Launcher.run(Launcher.java:284)
         at org.apache.tools.ant.launch.Launcher.main(Launcher.java:101)



From: Avanish Kant <ak...@manh.com>
Date: Wednesday, 20 November 2019 at 1:38 PM
To: "user@ant.apache.org" <user@ant.apache.org>
Subject: ConcurrentModificationException when running with Parallel-Ant executor

This relates to the issue and fix provided as a part of following PR.

https://github.com/apache/ant/pull/81

I understand that this fix is available as part of Ant 1.10.6. However I 
continue to face this problem even with Ant 1.10.6.

I have a new task defined (run-module-target) in one of my build script 
(macro-library.xml), which gets called by another build script 
(common-include.xml).

/builds/v2020/demand-forecasting/scpp-stable-source/scpp-builder/build/common-include.xml:564:
 The following error occurred while executing this line:
/builds/v2020/demand-forecasting/scpp-stable-source/scpp-builder/build/macro-library.xml:880:
 The following error occurred while executing this line:
/builds/v2020/demand-forecasting/scpp-stable-source/scpp-builder/build/macro-library.xml:890:
 java.util.ConcurrentModificationException.

Above ConcurrentModificationException is thrown by following line of code in 
macro-library.xml (details can be found in the code snippet below).
<ant antfile="${@{module}.config.dir}/@{module}-build.xml" inheritRefs="true" 
target="@{target}">

Please note that this issue happens intermittently. I did not get the complete 
exception trace as seen on the PR. Do I need to run ant command with verbose 
flag?

Code snippet from common-include.xml:

        <!-- - - - - - - - - - - - - - - - -->

        <!-- M a c r o   F u n c t i o n s -->

        <!-- - - - - - - - - - - - - - - - -->

        <import file="macro-library.xml" />


        <target name="war" depends="-init,-fetch-runtime-lib">

                <prepare-war />

                <run-module-target modules="${user.modules}" target="post-war" 
parallel="true" target.optional="true" />

                <print-timestamp target="war" />

        </target>


Code snippet from macro-library.xml:
                <macrodef name="run-module-target">
                                <attribute name="modules"/>
                                <attribute name="target"/>
                                <attribute name="parallel" default="false" />
                                <attribute name="target.optional" 
default="false" />
                                <sequential>
                                                <for list="@{modules}" 
param="module" parallel="@{parallel}">
                                                                <sequential>
                                                                                
<property name="@{module}.config.dir" value="${@{module}.module.dir}/Config/" />
                                                                                
<available property="@{module}.exists" file="${@{module}.config.dir}" 
type="dir" />
                                                                                
<if>
                                                                                
                <equals arg1="${@{module}.exists}" arg2="true" />
                                                                                
                <then>
                                                                                
                                <trycatch property="@{module}.@{target}.prop" 
reference="@{module}.@{target}.ref">
                                                                                
                                                <try>
                                                                                
                                                                <echo 
message="processing target '@{target}' for module @{module}"/>
                                                                                
                                                                <ant 
antfile="${@{module}.config.dir}/@{module}-build.xml" inheritRefs="true" 
target="@{target}">
                                                                                
                                                                                
<property name="modulename"                                                 
value="@{module}" />
                                                                                
                                                                                
<property name="module.classes.dir"         value="${global.war.classes.dir}" />
                                                                                
                                                                                
<property name="module.impl.dir"                                 
value="${global.war.classes.dir}" />
                                                                                
                                                                </ant>
                                                                                
                                                </try>
                                                                                
                                                <catch>
                                                                                
                                                                <if>
                                                                                
                                                                                
<and>
                                                                                
                                                                                
                  <contains casesensitive="false" 
string="${@{module}.@{target}.prop}" substring="&quot;@{target}&quot; does not 
exist in the project" />
                                                                                
                                                                                
                  <equals arg1="@{target.optional}" arg2="true" />
                                                                                
                                                                                
</and>
                                                                                
                                                                                
<then>
                                                                                
                                                                                
                <echo message="Error running the target : 
${@{module}.@{target}.prop}" level="verbose" />
                                                                                
                                                                                
                <echo message="Optional target @{target} does not exist in 
${@{module}.config.dir}/@{module}-build.xml. So skipping it" />
                                                                                
                                                                                
</then>
                                                                                
                                                                                
<else>
                                                                                
                                                                                
                <throw refid="@{module}.@{target}.ref" />
                                                                                
                                                                                
</else>
                                                                                
                                                                </if>
                                                                                
                                                </catch>
                                                                                
                                </trycatch>
                                                                                
                </then>
                                                                                
                <else>
                                                                                
                                <echo>@{module} found in composition but 
${@{module}.module.dir}/Config does not exist. Target '@{target}' for @{module} 
will be skipped</echo>
                                                                                
                </else>
                                                                                
</if>
                                                                </sequential>
                                                </for>
                                </sequential>
</macrodef>



Thanks,
Avanish

Reply via email to