This is an automated email from the ASF dual-hosted git repository.

reta pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cxf-xjc-utils.git


The following commit(s) were added to refs/heads/main by this push:
     new 7348bfe  Fix intermittent ArrayIndexOutOfBoundsException during stderr 
processing (#303)
7348bfe is described below

commit 7348bfeca088d0257d0243f187afc3ec18e464b9
Author: Guillaume Nodet <[email protected]>
AuthorDate: Wed Mar 11 16:07:23 2026 +0100

    Fix intermittent ArrayIndexOutOfBoundsException during stderr processing 
(#303)
    
    * Fix intermittent ArrayIndexOutOfBoundsException during stderr processing
    
    The same StreamConsumer instance was shared between the stdout and stderr
    StreamPumper threads in CommandLineUtils.executeCommandLine(). Since
    StreamConsumer has non-thread-safe mutable state (StringBuilder, File,
    int fields), concurrent access from both threads caused
    ArrayIndexOutOfBoundsException inside StringBuilder's System.arraycopy.
    
    Use separate StreamConsumer instances for stdout and stderr to eliminate
    the race condition.
    
    Co-Authored-By: Claude Opus 4.6 <[email protected]>
    
    * Use synchronized on shared StreamConsumer instead of separate instances
    
    Address review feedback: use a single shared StreamConsumer with
    synchronized consumeLine() to protect both the consumer's internal
    state and the buildContext writes from concurrent access by the
    stdout and stderr StreamPumper threads.
    
    Co-Authored-By: Claude Opus 4.6 <[email protected]>
    
    ---------
    
    Co-authored-by: Claude Opus 4.6 <[email protected]>
---
 .../java/org/apache/cxf/maven_plugin/AbstractXSDToJavaMojo.java   | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git 
a/cxf-xjc-plugin/src/main/java/org/apache/cxf/maven_plugin/AbstractXSDToJavaMojo.java
 
b/cxf-xjc-plugin/src/main/java/org/apache/cxf/maven_plugin/AbstractXSDToJavaMojo.java
index 350fc6f..ce0d822 100644
--- 
a/cxf-xjc-plugin/src/main/java/org/apache/cxf/maven_plugin/AbstractXSDToJavaMojo.java
+++ 
b/cxf-xjc-plugin/src/main/java/org/apache/cxf/maven_plugin/AbstractXSDToJavaMojo.java
@@ -553,8 +553,8 @@ public abstract class AbstractXSDToJavaMojo extends 
AbstractMojo {
             int linenum;
             int column;
             StringBuilder message = new StringBuilder();
-            
-            public void consumeLine(String line) {
+
+            public synchronized void consumeLine(String line) {
                 if (getLog().isDebugEnabled()) {
                     getLog().debug(line);
                 }
@@ -593,7 +593,7 @@ public abstract class AbstractXSDToJavaMojo extends 
AbstractMojo {
             getLog().debug(e);
             throw new MojoExecutionException(e.getMessage(), e);
         }
-        
+
 
         String cmdLine = CommandLineUtils.toString(cmd.getCommandline());
 
@@ -609,5 +609,5 @@ public abstract class AbstractXSDToJavaMojo extends 
AbstractMojo {
         file.delete();
         return 0;
     }
-    
+
 }

Reply via email to