提交 e147c51f 编写于 作者: C Christoph Kutzinski

there has been still a possible race condition in SurefireArchiver -...

there has been still a possible race condition in SurefireArchiver - synchronizing the whole block on build
上级 b093f44c
......@@ -124,12 +124,10 @@ public class SurefireArchiver extends MavenReporter {
if(reportsDir.exists()) {
// surefire:test just skips itself when the current project is not a java project
synchronized (build) {
FileSet fileSet = getFileSet(reportsDir);
DirectoryScanner ds;
synchronized (fileSet) {
ds = fileSet.getDirectoryScanner();
}
DirectoryScanner ds = fileSet.getDirectoryScanner();
if(ds.getIncludedFilesCount()==0)
// no test in this module
......@@ -141,9 +139,7 @@ public class SurefireArchiver extends MavenReporter {
if(result==null) result = new TestResult();
result.parse(System.currentTimeMillis() - build.getMilliSecsSinceBuildStart(), reportsDir, reportFiles);
int failCount;
synchronized (build) {
failCount = build.execute(new BuildCallable<Integer, IOException>() {
int failCount = build.execute(new BuildCallable<Integer, IOException>() {
public Integer call(MavenBuild build) throws IOException, InterruptedException {
SurefireReport sr = build.getAction(SurefireReport.class);
if(sr==null)
......@@ -156,7 +152,6 @@ public class SurefireArchiver extends MavenReporter {
return result.getFailCount();
}
});
}
// if surefire plugin is going to kill maven because of a test failure,
// intercept that (or otherwise build will be marked as failure)
......@@ -168,6 +163,7 @@ public class SurefireArchiver extends MavenReporter {
Maven3Builder.markAsSuccess = true;
}
}
}
return true;
}
......
......@@ -38,6 +38,11 @@ import org.junit.Before;
import org.junit.Test;
import org.mockito.Matchers;
/**
* Unit test for the JUnit result parsing in {@link SurefireArchiver}.
*
* @author kutzi
*/
public class SurefireArchiverUnitTest {
private SurefireArchiver archiver;
......@@ -87,7 +92,6 @@ public class SurefireArchiverUnitTest {
URL resource = SurefireArchiverUnitTest.class.getResource("/surefire-archiver-test1");
File reportsDir = new File(resource.toURI().getPath());
doReturn(reportsDir).when(this.mojoInfo).getConfigurationValue("reportsDirectory", File.class);
System.out.println("Using reports directory: " + reportsDir.getAbsolutePath());
this.archiver.postExecute(buildProxy, null, this.mojoInfo, new NullBuildListener(), null);
......@@ -100,7 +104,6 @@ public class SurefireArchiverUnitTest {
URL resource = SurefireArchiverUnitTest.class.getResource("/surefire-archiver-test2");
File reportsDir = new File(resource.toURI().getPath());
doReturn(reportsDir).when(this.mojoInfo).getConfigurationValue("reportsDirectory", File.class);
System.out.println("Using reports directory: " + reportsDir.getAbsolutePath());
touchReportFiles(reportsDir);
this.archiver.postExecute(buildProxy, null, this.mojoInfo, new NullBuildListener(), null);
......@@ -115,7 +118,6 @@ public class SurefireArchiverUnitTest {
resource = SurefireArchiverUnitTest.class.getResource("/surefire-archiver-test3");
reportsDir = new File(resource.toURI().getPath());
doReturn(reportsDir).when(this.mojoInfo).getConfigurationValue("reportsDirectory", File.class);
System.out.println("Using reports directory: " + reportsDir.getAbsolutePath());
touchReportFiles(reportsDir);
this.archiver.postExecute(buildProxy, null, this.mojoInfo, new NullBuildListener(), null);
......@@ -132,7 +134,6 @@ public class SurefireArchiverUnitTest {
URL resource = SurefireArchiverUnitTest.class.getResource("/surefire-archiver-test2");
File reportsDir = new File(resource.toURI().getPath());
doReturn(reportsDir).when(this.mojoInfo).getConfigurationValue("reportsDirectory", File.class);
System.out.println("Using reports directory: " + reportsDir.getAbsolutePath());
touchReportFiles(reportsDir);
FileSet fileSet = this.archiver.getFileSet(reportsDir);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册