Skip to content
Permalink
Browse files
[FIXED JENKINS-11256] SurefireArchiver#result doesn't need to be seri…
…alized on each remote call. Fixes ConcurrentModificationExceptions in MavenFingerprinter

Originally-Committed-As: 1476b2ee446f27b0c4ce85c16c5f984ef84cc8a4
  • Loading branch information
kutzi committed Nov 18, 2011
1 parent 3389f37 commit 00f1af0b4e71f8c691e36a1bb741eeff7bd512ee
Showing with 10 additions and 17 deletions.
  1. +10 −17 src/main/java/hudson/maven/reporters/SurefireArchiver.java
@@ -50,8 +50,6 @@
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;

import org.apache.commons.lang.StringUtils;
import org.apache.maven.artifact.versioning.ComparableVersion;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.project.MavenProject;
import org.apache.tools.ant.DirectoryScanner;
@@ -65,7 +63,7 @@
* @author Kohsuke Kawaguchi
*/
public class SurefireArchiver extends MavenReporter {
private TestResult result;
private transient TestResult result;

/**
* Store the filesets here as we want to track ignores between multiple runs of this class<br/>
@@ -82,7 +80,7 @@ public boolean preExecute(MavenBuildProxy build, MavenProject pom, MojoInfo mojo
// note that because of the way Maven works, just updating system property at this point is too late
XmlPlexusConfiguration c = (XmlPlexusConfiguration) mojo.configuration.getChild("testFailureIgnore");
if(c!=null && c.getValue() != null && c.getValue().equals("${maven.test.failure.ignore}") && System.getProperty("maven.test.failure.ignore")==null) {
if (maven3orLater( build.getMavenBuildInformation().getMavenVersion() )) {
if (build.getMavenBuildInformation().isMaven3OrLater()) {
String fieldName = "testFailureIgnore";
if (mojo.mojoExecution.getConfiguration().getChild( fieldName ) != null) {
mojo.mojoExecution.getConfiguration().getChild( fieldName ).setValue( Boolean.TRUE.toString() );
@@ -138,20 +136,23 @@ public boolean postExecute(MavenBuildProxy build, MavenProject pom, MojoInfo moj

if(result==null) result = new TestResult();
result.parse(System.currentTimeMillis() - build.getMilliSecsSinceBuildStart(), reportsDir, reportFiles);

// final reference in order to serialize it:
final TestResult r = result;

int failCount = build.execute(new BuildCallable<Integer, IOException>() {
private static final long serialVersionUID = -1023888330720922136L;

public Integer call(MavenBuild build) throws IOException, InterruptedException {
SurefireReport sr = build.getAction(SurefireReport.class);
if(sr==null)
build.getActions().add(new SurefireReport(build, result, listener));
build.getActions().add(new SurefireReport(build, r, listener));
else
sr.setResult(result,listener);
if(result.getFailCount()>0)
sr.setResult(r,listener);
if(r.getFailCount()>0)
build.setResult(Result.UNSTABLE);
build.registerAsProjectAction(new FactoryImpl());
return result.getFailCount();
return r.getFailCount();
}
});

@@ -160,7 +161,7 @@ public Integer call(MavenBuild build) throws IOException, InterruptedException {
if(failCount>0 && error instanceof MojoFailureException) {
MavenBuilder.markAsSuccess = true;
}
// TODO currenlty error is empty : will be here with maven 3.0.2+
// TODO currently error is empty : will be here with maven 3.0.2+
if(failCount>0) {
Maven3Builder.markAsSuccess = true;
}
@@ -307,14 +308,6 @@ else if (mojo.is("org.sonatype.flexmojos", "flexmojos-maven-plugin", "test-run")
return true;
}

public boolean maven3orLater(String mavenVersion) {
// null or empty so false !
if (StringUtils.isBlank( mavenVersion )) {
return false;
}
return new ComparableVersion (mavenVersion).compareTo( new ComparableVersion ("3.0") ) >= 0;
}

// I'm not sure if SurefireArchiver is actually ever (de-)serialized,
// but just to be sure, set fileSets here
protected Object readResolve() {

0 comments on commit 00f1af0

Please sign in to comment.