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 1010
1111package org .junit .jupiter .engine .descriptor ;
1212
13+ import static java .util .Collections .emptyList ;
14+ import static java .util .Collections .unmodifiableList ;
1315import static org .junit .platform .commons .support .AnnotationSupport .findAnnotation ;
1416
1517import java .lang .reflect .AnnotatedElement ;
@@ -121,14 +123,18 @@ private static Supplier<String> createDisplayNameSupplier(Supplier<List<Class<?>
121123 Class <?> testClass , JupiterConfiguration configuration ,
122124 BiFunction <DisplayNameGenerator , List <Class <?>>, String > generatorFunction ) {
123125 return () -> {
124- List <Class <?>> enclosingInstanceTypes = enclosingInstanceTypesSupplier .get ();
126+ List <Class <?>> enclosingInstanceTypes = makeUnmodifiable ( enclosingInstanceTypesSupplier .get () );
125127 return findDisplayNameGenerator (enclosingInstanceTypes , testClass ) //
126128 .map (it -> generatorFunction .apply (it , enclosingInstanceTypes )) //
127129 .orElseGet (() -> generatorFunction .apply (configuration .getDefaultDisplayNameGenerator (),
128130 enclosingInstanceTypes ));
129131 };
130132 }
131133
134+ private static <T > List <T > makeUnmodifiable (List <T > list ) {
135+ return list .isEmpty () ? emptyList () : unmodifiableList (list );
136+ }
137+
132138 private static Optional <DisplayNameGenerator > findDisplayNameGenerator (List <Class <?>> enclosingInstanceTypes ,
133139 Class <?> testClass ) {
134140 Preconditions .notNull (testClass , "Test class must not be null" );
You can’t perform that action at this time.
0 commit comments