Skip to content

Commit 63d97b1

Browse files
committed
Pass unmodifiable lists to ResourceLocksProvider
1 parent 36019b7 commit 63d97b1

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

junit-jupiter-engine/src/main/java/org/junit/jupiter/engine/descriptor/ResourceLockAware.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
package org.junit.jupiter.engine.descriptor;
1212

13+
import static java.util.Collections.emptyList;
14+
import static java.util.Collections.unmodifiableList;
1315
import static org.junit.jupiter.api.parallel.ResourceLockTarget.CHILDREN;
1416

1517
import java.util.ArrayDeque;
@@ -76,10 +78,14 @@ static Function<ResourceLocksProvider, Set<ResourceLocksProvider.Lock>> enclosin
7678
@Override
7779
public Set<ResourceLocksProvider.Lock> apply(ResourceLocksProvider provider) {
7880
if (this.enclosingInstanceTypes == null) {
79-
this.enclosingInstanceTypes = enclosingInstanceTypesSupplier.get();
81+
this.enclosingInstanceTypes = makeUnmodifiable(enclosingInstanceTypesSupplier.get());
8082
}
8183
return evaluator.apply(provider, this.enclosingInstanceTypes);
8284
}
85+
86+
private <T> List<T> makeUnmodifiable(List<T> list) {
87+
return list.isEmpty() ? emptyList() : unmodifiableList(list);
88+
}
8389
};
8490
}
8591

0 commit comments

Comments
 (0)