Skip to content

Commit 404ff07

Browse files
committed
Prevent concurrently running Jacoco ReportCreators to avoid report corruption
1 parent 7759deb commit 404ff07

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

test-framework/jacoco/runtime/src/main/java/io/quarkus/jacoco/runtime/ReportCreator.java

+10
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,16 @@ public ReportCreator(ReportInfo reportInfo, JacocoConfig config) {
3737

3838
@Override
3939
public void run() {
40+
// Ugly workaround:
41+
// Multiple ReportCreator shutdown hooks might run concurrently, possibly corrupting the report file(s) - e.g. when using @TestProfile.
42+
// By locking on a class from the parent CL, all hooks are "serialized", one after another.
43+
// In the long run there should only be as many hooks as there are different Jacoco configs...usually there will be only one config anyway!
44+
synchronized (ExecFileLoader.class) {
45+
doRun();
46+
}
47+
}
48+
49+
private void doRun() {
4050
File targetdir = new File(reportInfo.reportDir);
4151
targetdir.mkdirs();
4252
try {

0 commit comments

Comments
 (0)