File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed
junit-jupiter-engine/src/main/java/org/junit/jupiter/engine/descriptor Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change 10
10
11
11
package org .junit .jupiter .engine .descriptor ;
12
12
13
+ import static java .util .Collections .emptyList ;
14
+ import static java .util .Collections .unmodifiableList ;
13
15
import static org .junit .platform .commons .support .AnnotationSupport .findAnnotation ;
14
16
15
17
import java .lang .reflect .AnnotatedElement ;
@@ -121,14 +123,18 @@ private static Supplier<String> createDisplayNameSupplier(Supplier<List<Class<?>
121
123
Class <?> testClass , JupiterConfiguration configuration ,
122
124
BiFunction <DisplayNameGenerator , List <Class <?>>, String > generatorFunction ) {
123
125
return () -> {
124
- List <Class <?>> enclosingInstanceTypes = enclosingInstanceTypesSupplier .get ();
126
+ List <Class <?>> enclosingInstanceTypes = makeUnmodifiable ( enclosingInstanceTypesSupplier .get () );
125
127
return findDisplayNameGenerator (enclosingInstanceTypes , testClass ) //
126
128
.map (it -> generatorFunction .apply (it , enclosingInstanceTypes )) //
127
129
.orElseGet (() -> generatorFunction .apply (configuration .getDefaultDisplayNameGenerator (),
128
130
enclosingInstanceTypes ));
129
131
};
130
132
}
131
133
134
+ private static <T > List <T > makeUnmodifiable (List <T > list ) {
135
+ return list .isEmpty () ? emptyList () : unmodifiableList (list );
136
+ }
137
+
132
138
private static Optional <DisplayNameGenerator > findDisplayNameGenerator (List <Class <?>> enclosingInstanceTypes ,
133
139
Class <?> testClass ) {
134
140
Preconditions .notNull (testClass , "Test class must not be null" );
You can’t perform that action at this time.
0 commit comments