cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Falko Modler (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (CXF-7083) Maven Plugins: System properties handling in ClassLoaderSwitcher breaks thread safety
Date Tue, 11 Oct 2016 16:26:21 GMT

     [ https://issues.apache.org/jira/browse/CXF-7083?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Falko Modler updated CXF-7083:
------------------------------
    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:
{code:java|title=https://github.com/apache/cxf/blob/cxf-2.7.18/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/WSDL2JavaMojo.java}
/**
 * @goal wsdl2java
 * @phase generate-sources
 * @description CXF WSDL To Java Tool
 * @requiresDependencyResolution test
 * @threadSafe
 */
public class WSDL2JavaMojo extends AbstractCodegenMoho {
...
{code}
But from time to time (maybe 5% of our builds) we see following exception causing the respective
build to fail:
{noformat}
[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
{noformat}
There seems to be a write access from another thread while {{ClassLoaderSwitcher}} tries to
copy the system properties:
{code:java|title=https://github.com/apache/cxf/blob/cxf-2.7.18/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/common/ClassLoaderSwitcher.java#L131}
        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);
}
{code}

*Possible solutions*:
- synchronize on {{System.getProperties()}} in the entire block (lines 129-135)
- create a clone
{code:java}
(Properties) System.getProperties().clone()
{code}
and instead of {{.putAll()}} use {{.setProperties(...)}}

I haven't checked {{ClassLoaderSwitcher .switchClassLoader()}} but I guess something similar
needs to be done there.

  was:
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:
{code:java|title=https://github.com/apache/cxf/blob/cxf-2.7.18/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/WSDL2JavaMojo.java}
/**
 * @goal wsdl2java
 * @phase generate-sources
 * @description CXF WSDL To Java Tool
 * @requiresDependencyResolution test
 * @threadSafe
 */
public class WSDL2JavaMojo extends AbstractCodegenMoho {
...
{code}
But from time to time (maybe 5% of our builds) we see following exception causing the respective
build to fail:
{noformat}
[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 patientenService 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
{noformat}
There seems to be a write access from another thread while {{ClassLoaderSwitcher}} tries to
copy the system properties:
{code:java|title=https://github.com/apache/cxf/blob/cxf-2.7.18/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/common/ClassLoaderSwitcher.java#L131}
        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);
}
{code}

*Possible solutions*:
- synchronize on {{System.getProperties()}} in the entire block (lines 129-135)
- create a clone
{code:java}
(Properties) System.getProperties().clone()
{code}
and instead of {{.putAll()}} use {{.setProperties(...)}}

I haven't checked {{ClassLoaderSwitcher .switchClassLoader()}} but I guess something similar
needs to be done there.


> Maven Plugins: System properties handling in ClassLoaderSwitcher breaks thread safety
> -------------------------------------------------------------------------------------
>
>                 Key: CXF-7083
>                 URL: https://issues.apache.org/jira/browse/CXF-7083
>             Project: CXF
>          Issue Type: Bug
>          Components: Tooling
>    Affects Versions: 2.7.18
>         Environment: 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"
>            Reporter: Falko Modler
>
> 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:
> {code:java|title=https://github.com/apache/cxf/blob/cxf-2.7.18/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/WSDL2JavaMojo.java}
> /**
>  * @goal wsdl2java
>  * @phase generate-sources
>  * @description CXF WSDL To Java Tool
>  * @requiresDependencyResolution test
>  * @threadSafe
>  */
> public class WSDL2JavaMojo extends AbstractCodegenMoho {
> ...
> {code}
> But from time to time (maybe 5% of our builds) we see following exception causing the
respective build to fail:
> {noformat}
> [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
> {noformat}
> There seems to be a write access from another thread while {{ClassLoaderSwitcher}} tries
to copy the system properties:
> {code:java|title=https://github.com/apache/cxf/blob/cxf-2.7.18/maven-plugins/wadl2java-plugin/src/main/java/org/apache/cxf/maven_plugin/common/ClassLoaderSwitcher.java#L131}
>         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);
> }
> {code}
> *Possible solutions*:
> - synchronize on {{System.getProperties()}} in the entire block (lines 129-135)
> - create a clone
> {code:java}
> (Properties) System.getProperties().clone()
> {code}
> and instead of {{.putAll()}} use {{.setProperties(...)}}
> I haven't checked {{ClassLoaderSwitcher .switchClassLoader()}} but I guess something
similar needs to be done there.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message