dev@jax-ws-commons.java.net

Re: jaxws-maven-plugin thread synchronization

From: Elie Kassis <ekassis_at_hotmail.com>
Date: Thu, 26 Sep 2013 17:56:32 +0000

Hi,

It does not make it thread safe. It increases the safety of multi threading enough to make my compilation with 3 threads on quad cores processor not to fail.

Can you please let me know how we can push my fixes to the official release?


Sent via my BlackBerry® smartphone from Alfa

-----Original Message-----
From: Lukas Jungmann <lukas.jungmann_at_oracle.com>
Date: Tue, 24 Sep 2013 13:43:15
To: <dev_at_jax-ws-commons.java.net>
Cc: <ekassis_at_hotmail.com>
Subject: Re: jaxws-maven-plugin thread synchronization

[removed issues_at_jax-ws-commons.java.net <mailto:issues_at_jax-ws-commons.java.net> ]
 
 Hi Elie,
 
 
 On 9/24/13 11:39 AM, Elie Kassis wrote:
 
 
Hi,
 
I'm running a very large build using a CI server and I'm facing regular failures when running in multithread maven plugin mode. (1 out of 10 builds fail)
 
I tested patching jaxws-maven-plugin adding the below patch that fixed the issue and I have 0 failures at the moment.
 thanks for it. After this change would it be safe to mark mojos as threadSafe=true? Can you check that, please?
 There's also related https://java.net/jira/browse/JAX_WS_COMMONS-88 issue for this...
 
 --lukas
 
 
 
 
 
Can you please tell me how can I integrate this fix into the future versions so I can maintain my compatibility with future releases?
 
Thank you.
 
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>1.10</version>
 
Index: src/main/java/org/codehaus/mojo/jaxws/AbstractWsGenMojo.java
===================================================================
--- src/main/java/org/codehaus/mojo/jaxws/AbstractWsGenMojo.java               (revision 1165)
+++ src/main/java/org/codehaus/mojo/jaxws/AbstractWsGenMojo.java            (working copy)
@@ -34,6 +34,7 @@
  * @version $Id: WsGenMojo.java 3169 2007-01-22 02:51:29Z dantran $
  */
 abstract class AbstractWsGenMojo extends AbstractJaxwsMojo {
+             private static Object lock = new Object();
 
     /**
      * Specify that a WSDL file should be generated in ${resourceDestDir}
@@ -85,6 +86,8 @@
 
     public void execute()
         throws MojoExecutionException, MojoFailureException {
+             synchronized (lock) {                                     
+                            
         init();
 
         // Need to build a URLClassloader since Maven removed it form the chain
@@ -105,6 +108,7 @@
             Thread.currentThread().setContextClassLoader(parent);
             System.setProperty("java.class.path", orginalSystemClasspath);
         }
+             }
     }
 
     private void init() throws MojoExecutionException, MojoFailureException {
Index: src/main/java/org/codehaus/mojo/jaxws/MainWsGenMojo.java
===================================================================
--- src/main/java/org/codehaus/mojo/jaxws/MainWsGenMojo.java     (revision 1165)
+++ src/main/java/org/codehaus/mojo/jaxws/MainWsGenMojo.java  (working copy)
@@ -10,6 +10,7 @@
  * @phase process-classes
  * @requiresDependencyResolution
  * @description generate JAX-WS wrapper beans.
+ * @threadSafe
  */
 public class MainWsGenMojo extends AbstractWsGenMojo {
     /**
Index: src/main/java/org/codehaus/mojo/jaxws/MainWsImportMojo.java
===================================================================
--- src/main/java/org/codehaus/mojo/jaxws/MainWsImportMojo.java                (revision 1165)
+++ src/main/java/org/codehaus/mojo/jaxws/MainWsImportMojo.java             (working copy)
@@ -8,7 +8,8 @@
  * @goal wsimport
  * @phase generate-sources
  * @requiresDependencyResolution
- * @description JAXWS 2.x Plugin.
+ * @description JAXWS 2.x Plugin
+ * @threadSafe
  *
  * @author Kohsuke Kawaguchi
  */
Index: src/main/java/org/codehaus/mojo/jaxws/WsImportMojo.java
===================================================================
--- src/main/java/org/codehaus/mojo/jaxws/WsImportMojo.java          (revision 1165)
+++ src/main/java/org/codehaus/mojo/jaxws/WsImportMojo.java       (working copy)
@@ -34,6 +34,7 @@
  */
 abstract class WsImportMojo extends AbstractJaxwsMojo
 {
+             private static Object lock  = new Object();
 
     /**
      * The package in which the source files will be generated.
@@ -175,7 +176,8 @@
     public void execute()
         throws MojoExecutionException
     {
-
+             synchronized (lock) {                                     
+                            
         // Need to build a URLClassloader since Maven removed it form the chain
         ClassLoader parent = this.getClass().getClassLoader();
         String originalSystemClasspath = this.initClassLoader( parent );
@@ -209,6 +211,7 @@
             Thread.currentThread().setContextClassLoader( parent );
             System.setProperty( "java.class.path", originalSystemClasspath );
         }
+             }
 
     }
 
 
Regards,
Elie