You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by pg...@apache.org on 2012/06/28 17:30:37 UTC
svn commit: r1355045 -
/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/TestSetRunListener.java
Author: pgier
Date: Thu Jun 28 15:30:36 2012
New Revision: 1355045
URL: http://svn.apache.org/viewvc?rev=1355045&view=rev
Log:
SUREFIRE-879 maven-surefire-report-plugin fails some times with ConcurrentModificationException when running parallel TestNG
The issue is easily fixed by atomically getting the array of elements and iterating over it rather than the list of buffers.
Modified:
maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/TestSetRunListener.java
Modified: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/TestSetRunListener.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/TestSetRunListener.java?rev=1355045&r1=1355044&r2=1355045&view=diff
==============================================================================
--- maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/TestSetRunListener.java (original)
+++ maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/TestSetRunListener.java Thu Jun 28 15:30:36 2012
@@ -206,7 +206,10 @@ public class TestSetRunListener
public String getAsString( List<ByteBuffer> byteBufferList )
{
StringBuilder stringBuffer = new StringBuilder();
- for ( ByteBuffer byteBuffer : byteBufferList )
+ // To avoid getting a java.util.ConcurrentModificationException while iterating (see SUREFIRE-879) we need to
+ // iterate over a copy or the elements array. Since the passed in byteBufferList is always wrapped with
+ // Collections.synchronizedList( ) we are guaranteed toArray() is going to be atomic, so we are safe.
+ for ( Object byteBuffer : byteBufferList.toArray() )
{
stringBuffer.append( byteBuffer.toString() );
}