From 90d8480ffe8fe7672a575bba49f8f8c423f25d4d Mon Sep 17 00:00:00 2001 From: XenoAmess Date: Fri, 3 Jul 2020 18:40:24 +0800 Subject: [PATCH] Use new ArrayList(Collection) rather than new, iterate, and add See gh-22210 --- .../boot/autoconfigure/AutoConfigurationPackages.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigurationPackages.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigurationPackages.java index d37dc97f56..142c1d41e7 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigurationPackages.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigurationPackages.java @@ -141,10 +141,7 @@ public abstract class AutoConfigurationPackages { PackageImports(AnnotationMetadata metadata) { AnnotationAttributes attributes = AnnotationAttributes .fromMap(metadata.getAnnotationAttributes(AutoConfigurationPackage.class.getName(), false)); - List packageNames = new ArrayList<>(); - for (String basePackage : attributes.getStringArray("basePackages")) { - packageNames.add(basePackage); - } + List packageNames = new ArrayList<>(Arrays.asList(attributes.getStringArray("basePackages"))); for (Class basePackageClass : attributes.getClassArray("basePackageClasses")) { packageNames.add(basePackageClass.getPackage().getName()); }