From d7090b500ba680d1204a9bb0ba6fb16f8b1a5946 Mon Sep 17 00:00:00 2001 From: biergit Date: Sat, 5 Nov 2022 13:35:36 +0100 Subject: [PATCH 1/2] Polish ImportCandidates See gh-33013 --- .../context/annotation/ImportCandidates.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/annotation/ImportCandidates.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/annotation/ImportCandidates.java index db7141de823..a3d98995694 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/annotation/ImportCandidates.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/annotation/ImportCandidates.java @@ -73,12 +73,12 @@ public final class ImportCandidates implements Iterable { ClassLoader classLoaderToUse = decideClassloader(classLoader); String location = String.format(LOCATION, annotation.getName()); Enumeration urls = findUrlsInClasspath(classLoaderToUse, location); - List autoConfigurations = new ArrayList<>(); + List importCandidates = new ArrayList<>(); while (urls.hasMoreElements()) { URL url = urls.nextElement(); - autoConfigurations.addAll(readAutoConfigurations(url)); + importCandidates.addAll(readCandidateConfigurations(url)); } - return new ImportCandidates(autoConfigurations); + return new ImportCandidates(importCandidates); } private static ClassLoader decideClassloader(ClassLoader classLoader) { @@ -93,15 +93,15 @@ public final class ImportCandidates implements Iterable { return classLoader.getResources(location); } catch (IOException ex) { - throw new IllegalArgumentException("Failed to load autoconfigurations from location [" + location + "]", + throw new IllegalArgumentException("Failed to load configurations from location [" + location + "]", ex); } } - private static List readAutoConfigurations(URL url) { + private static List readCandidateConfigurations(URL url) { try (BufferedReader reader = new BufferedReader( new InputStreamReader(new UrlResource(url).getInputStream(), StandardCharsets.UTF_8))) { - List autoConfigurations = new ArrayList<>(); + List candidates = new ArrayList<>(); String line; while ((line = reader.readLine()) != null) { line = stripComment(line); @@ -109,12 +109,12 @@ public final class ImportCandidates implements Iterable { if (line.isEmpty()) { continue; } - autoConfigurations.add(line); + candidates.add(line); } - return autoConfigurations; + return candidates; } catch (IOException ex) { - throw new IllegalArgumentException("Unable to load autoconfigurations from location [" + url + "]", ex); + throw new IllegalArgumentException("Unable to load configurations from location [" + url + "]", ex); } } From 651f4f72360b970d1ad142dc7ffe1b8ddba8b22f Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Sun, 6 Nov 2022 11:30:06 +0000 Subject: [PATCH 2/2] Polish "Polish ImportCandidates" See gh-33013 --- .../boot/context/annotation/ImportCandidates.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/annotation/ImportCandidates.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/annotation/ImportCandidates.java index a3d98995694..8ab3572ef23 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/annotation/ImportCandidates.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/annotation/ImportCandidates.java @@ -93,8 +93,7 @@ public final class ImportCandidates implements Iterable { return classLoader.getResources(location); } catch (IOException ex) { - throw new IllegalArgumentException("Failed to load configurations from location [" + location + "]", - ex); + throw new IllegalArgumentException("Failed to load configurations from location [" + location + "]", ex); } }