Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.7.18
-
None
-
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T17:41:47+01:00)
Maven home: /usr/maven/default
Java version: 1.8.0_102, vendor: Oracle Corporation
Java home: /usr/java/jdk1.8.0_102/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "2.6.32-431.29.2.el6.x86_64", arch: "amd64", family: "unix"Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T17:41:47+01:00) Maven home: /usr/maven/default Java version: 1.8.0_102, vendor: Oracle Corporation Java home: /usr/java/jdk1.8.0_102/jre Default locale: en_US, platform encoding: UTF-8 OS name: "linux", version: "2.6.32-431.29.2.el6.x86_64", arch: "amd64", family: "unix"
-
Unknown
Description
We got a rather large Maven project with a couble of modules that execute cxf-codegen-plugin. Our builds runs in parallel mode via -Tx and according to the JavaDoc the plugin should be fine with that:
/** * @goal wsdl2java * @phase generate-sources * @description CXF WSDL To Java Tool * @requiresDependencyResolution test * @threadSafe */ public class WSDL2JavaMojo extends AbstractCodegenMoho { ...
But from time to time (maybe 5% of our builds) we see following exception causing the respective build to fail:
[ERROR] Failed to execute goal org.apache.cxf:cxf-codegen-plugin:2.7.18:wsdl2java (exampleExec) on project example-module: Execution exampleService of goal org.apache.cxf:cxf-codegen-plugin:2.7.18:wsdl2java failed. ConcurrentModificationException -> [Help 1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.cxf:cxf-codegen-plugin:2.7.18:wsdl2java (exampleExec) on project example-module: Execution exampleService of goal org.apache.cxf:cxf-codegen-plugin:2.7.18:wsdl2java failed. at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116) at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call(MultiThreadedBuilder.java:185) at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call(MultiThreadedBuilder.java:181) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) Caused by: org.apache.maven.plugin.PluginExecutionException: Execution exampleService of goal org.apache.cxf:cxf-codegen-plugin:2.7.18:wsdl2java failed. at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:145) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207) ... 11 more Caused by: java.util.ConcurrentModificationException at java.util.Hashtable$Enumerator.next(Hashtable.java:1378) at java.util.HashMap.putMapEntries(HashMap.java:511) at java.util.HashMap.<init>(HashMap.java:489) at org.apache.cxf.maven_plugin.ClassLoaderSwitcher.restoreClassLoader(ClassLoaderSwitcher.java:129) at org.apache.cxf.maven_plugin.AbstractCodegenMoho.execute(AbstractCodegenMoho.java:326) at org.apache.cxf.maven_plugin.wsdl2java.WSDL2JavaMojo.execute(WSDL2JavaMojo.java:524) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134) ... 12 more [ERROR] [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException
There seems to be a write access from another thread while ClassLoaderSwitcher tries to copy the system properties:
if (origProps != null) { Map<Object, Object> newProps = new HashMap<Object, Object>(System.getProperties()); for (Object o : newProps.keySet()) { if (!origProps.containsKey(o)) { System.clearProperty(o.toString()); } } System.getProperties().putAll(origProps); }
Possible solutions:
- synchronize on System.getProperties() in the entire block (lines 129-135)
- create a clone
(Properties) System.getProperties().clone()
and instead of .putAll() use .setProperties(...)
I haven't checked ClassLoaderSwitcher .switchClassLoader() but I guess something similar needs to be done there.