Author: krosenvold Date: Fri May 20 16:54:13 2011 New Revision: 1125462 URL: http://svn.apache.org/viewvc?rev=1125462&view=rev Log: [SUREFIRE-742] Improved error checking/logging and hardened validation somewhat
Modified: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkingRunListener.java Modified: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java?rev=1125462&r1=1125461&r2=1125462&view=diff ============================================================================== --- maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java (original) +++ maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java Fri May 20 16:54:13 2011 @@ -91,28 +91,28 @@ public class ForkClient switch ( operationId ) { case ForkingRunListener.BOOTERCODE_TESTSET_STARTING: - reporter.testSetStarting( createReportEntry( new StringTokenizer( remaining, "," ) ) ); + reporter.testSetStarting( createReportEntry( remaining ) ); break; case ForkingRunListener.BOOTERCODE_TESTSET_COMPLETED: - reporter.testSetCompleted( createReportEntry( new StringTokenizer( remaining, "," ) ) ); + reporter.testSetCompleted( createReportEntry( remaining ) ); break; case ForkingRunListener.BOOTERCODE_TEST_STARTING: - reporter.testStarting( createReportEntry( new StringTokenizer( remaining, "," ) ) ); + reporter.testStarting( createReportEntry( remaining) ); break; case ForkingRunListener.BOOTERCODE_TEST_SUCCEEDED: - reporter.testSucceeded( createReportEntry( new StringTokenizer( remaining, "," ) ) ); + reporter.testSucceeded( createReportEntry( remaining ) ); break; case ForkingRunListener.BOOTERCODE_TEST_FAILED: - reporter.testFailed( createReportEntry( new StringTokenizer( remaining, "," ) ) ); + reporter.testFailed( createReportEntry( remaining ) ); break; case ForkingRunListener.BOOTERCODE_TEST_SKIPPED: - reporter.testSkipped( createReportEntry( new StringTokenizer( remaining, "," ) ) ); + reporter.testSkipped( createReportEntry( remaining ) ); break; case ForkingRunListener.BOOTERCODE_TEST_ERROR: - reporter.testError( createReportEntry( new StringTokenizer( remaining, "," ) ) ); + reporter.testError( createReportEntry( remaining ) ); break; case ForkingRunListener.BOOTERCODE_TEST_ASSUMPTIONFAILURE: - reporter.testAssumptionFailure( createReportEntry( new StringTokenizer( remaining, "," ) ) ); + reporter.testAssumptionFailure( createReportEntry( remaining ) ); break; case ForkingRunListener.BOOTERCODE_SYSPROPS: int keyEnd = remaining.indexOf( "," ); @@ -169,8 +169,9 @@ public class ForkClient return unescape( remaining ); } - private ReportEntry createReportEntry( StringTokenizer tokens ) + private ReportEntry createReportEntry( String untokenized) { + StringTokenizer tokens = new StringTokenizer(untokenized, ","); try { String source = tokens.nextToken(); @@ -187,7 +188,7 @@ public class ForkClient } catch ( RuntimeException e ) { - throw new RuntimeException( tokens.toString(), e ); + throw new RuntimeException( untokenized, e ); } } @@ -195,7 +196,7 @@ public class ForkClient { StackTraceWriter stackTraceWriter; String stackTraceMessage = nullableCsv( tokens.nextToken() ); - String stackTrace = nullableCsv( tokens.nextToken() ); + String stackTrace = tokens.hasMoreTokens() ? nullableCsv( tokens.nextToken() ) : null; stackTraceWriter = stackTrace != null ? new DeserializedStacktraceWriter( stackTraceMessage, stackTrace ) : null; return stackTraceWriter; Modified: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkingRunListener.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkingRunListener.java?rev=1125462&r1=1125461&r2=1125462&view=diff ============================================================================== --- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkingRunListener.java (original) +++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkingRunListener.java Fri May 20 16:54:13 2011 @@ -221,8 +221,11 @@ public class ForkingRunListener StringUtils.escapeJavaStyleString( byteBuffer.getData(), byteBuffer.getlength(), buf, 0, buf.length ); byteBuffer.advance( i ); byteBuffer.append( '\n' ); - target.write( byteBuffer.getData(), 0, byteBuffer.getlength() ); - target.flush(); + synchronized ( target ) + { + target.write( byteBuffer.getData(), 0, byteBuffer.getlength() ); + target.flush(); + } } private String toPropertyString( String key, String value ) @@ -320,7 +323,6 @@ public class ForkingRunListener else { comma( stringBuffer ); - comma( stringBuffer ); } } }