From 73391ebd782453461a7160370b33760efb27b197 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Kautler?= Date: Tue, 9 May 2023 21:04:19 +0200 Subject: [PATCH] Make the test unit finder thread-safe --- src/main/java/org/pitest/junit5/JUnit5TestUnitFinder.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/pitest/junit5/JUnit5TestUnitFinder.java b/src/main/java/org/pitest/junit5/JUnit5TestUnitFinder.java index daa55fe..8d9b79f 100755 --- a/src/main/java/org/pitest/junit5/JUnit5TestUnitFinder.java +++ b/src/main/java/org/pitest/junit5/JUnit5TestUnitFinder.java @@ -19,6 +19,7 @@ import java.util.List; import static java.util.Collections.emptyList; +import static java.util.Collections.synchronizedList; import static java.util.Collections.unmodifiableList; import static java.util.stream.Collectors.toList; @@ -95,7 +96,7 @@ public List findTestUnits(Class clazz, TestUnitExecutionListener ex private class TestIdentifierListener implements TestExecutionListener { private final Class testClass; private final TestUnitExecutionListener l; - private final List identifiers = new ArrayList<>(); + private final List identifiers = synchronizedList(new ArrayList<>()); public TestIdentifierListener(Class testClass, TestUnitExecutionListener l) { this.testClass = testClass; @@ -103,7 +104,7 @@ public TestIdentifierListener(Class testClass, TestUnitExecutionListener l) { } List getIdentifiers() { - return unmodifiableList(identifiers); + return unmodifiableList(new ArrayList<>(identifiers)); } @Override