mirror of
https://github.com/spring-projects/spring-framework
synced 2026-06-08 17:33:33 +00:00
Avoid unnecessary List and Stream creation
See gh-36390
This commit is contained in:
+7
-8
@@ -298,15 +298,18 @@ public abstract class AbstractTestContextBootstrapper implements TestContextBoot
|
||||
https://docs.spring.io/spring-framework/reference/testing/testcontext-framework/ctx-management/default-config.html""";
|
||||
|
||||
Set<Class<?>> currentClasses = new HashSet<>(Arrays.asList(mergedConfig.getClasses()));
|
||||
List<Class<?>> ignoredClasses = Arrays.stream(completeMergedConfig.getClasses())
|
||||
.filter(clazz -> !currentClasses.contains(clazz)).toList();
|
||||
String ignoredClasses = Arrays.stream(completeMergedConfig.getClasses())
|
||||
.filter(clazz -> !currentClasses.contains(clazz))
|
||||
.map(Class::getName)
|
||||
.collect(Collectors.joining(", "));
|
||||
if (!ignoredClasses.isEmpty()) {
|
||||
logger.warn(warningMessage.formatted(testClass.getName(), "classes", names(ignoredClasses)));
|
||||
logger.warn(warningMessage.formatted(testClass.getName(), "classes", ignoredClasses));
|
||||
}
|
||||
|
||||
Set<String> currentLocations = new HashSet<>(Arrays.asList(mergedConfig.getLocations()));
|
||||
String ignoredLocations = Arrays.stream(completeMergedConfig.getLocations())
|
||||
.filter(location -> !currentLocations.contains(location)).collect(Collectors.joining(", "));
|
||||
.filter(location -> !currentLocations.contains(location))
|
||||
.collect(Collectors.joining(", "));
|
||||
if (!ignoredLocations.isEmpty()) {
|
||||
logger.warn(warningMessage.formatted(testClass.getName(), "locations", ignoredLocations));
|
||||
}
|
||||
@@ -663,10 +666,6 @@ public abstract class AbstractTestContextBootstrapper implements TestContextBoot
|
||||
}
|
||||
|
||||
|
||||
private static String names(Collection<Class<?>> classes) {
|
||||
return classes.stream().map(Class::getName).collect(Collectors.joining(", "));
|
||||
}
|
||||
|
||||
private static List<String> classSimpleNames(Collection<?> components) {
|
||||
return components.stream().map(Object::getClass).map(Class::getSimpleName).toList();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user