Skip to content

Commit e44b114

Browse files
committed
Merge pull request #33013 from biergit
* gh-33013: Polish "Polish ImportCandidates" Polish ImportCandidates Closes gh-33013
2 parents b4283d4 + 651f4f7 commit e44b114

File tree

1 file changed

+9
-10
lines changed
  • spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/annotation

1 file changed

+9
-10
lines changed

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/annotation/ImportCandidates.java

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,12 @@ public static ImportCandidates load(Class<?> annotation, ClassLoader classLoader
7373
ClassLoader classLoaderToUse = decideClassloader(classLoader);
7474
String location = String.format(LOCATION, annotation.getName());
7575
Enumeration<URL> urls = findUrlsInClasspath(classLoaderToUse, location);
76-
List<String> autoConfigurations = new ArrayList<>();
76+
List<String> importCandidates = new ArrayList<>();
7777
while (urls.hasMoreElements()) {
7878
URL url = urls.nextElement();
79-
autoConfigurations.addAll(readAutoConfigurations(url));
79+
importCandidates.addAll(readCandidateConfigurations(url));
8080
}
81-
return new ImportCandidates(autoConfigurations);
81+
return new ImportCandidates(importCandidates);
8282
}
8383

8484
private static ClassLoader decideClassloader(ClassLoader classLoader) {
@@ -93,28 +93,27 @@ private static Enumeration<URL> findUrlsInClasspath(ClassLoader classLoader, Str
9393
return classLoader.getResources(location);
9494
}
9595
catch (IOException ex) {
96-
throw new IllegalArgumentException("Failed to load autoconfigurations from location [" + location + "]",
97-
ex);
96+
throw new IllegalArgumentException("Failed to load configurations from location [" + location + "]", ex);
9897
}
9998
}
10099

101-
private static List<String> readAutoConfigurations(URL url) {
100+
private static List<String> readCandidateConfigurations(URL url) {
102101
try (BufferedReader reader = new BufferedReader(
103102
new InputStreamReader(new UrlResource(url).getInputStream(), StandardCharsets.UTF_8))) {
104-
List<String> autoConfigurations = new ArrayList<>();
103+
List<String> candidates = new ArrayList<>();
105104
String line;
106105
while ((line = reader.readLine()) != null) {
107106
line = stripComment(line);
108107
line = line.trim();
109108
if (line.isEmpty()) {
110109
continue;
111110
}
112-
autoConfigurations.add(line);
111+
candidates.add(line);
113112
}
114-
return autoConfigurations;
113+
return candidates;
115114
}
116115
catch (IOException ex) {
117-
throw new IllegalArgumentException("Unable to load autoconfigurations from location [" + url + "]", ex);
116+
throw new IllegalArgumentException("Unable to load configurations from location [" + url + "]", ex);
118117
}
119118
}
120119

0 commit comments

Comments
 (0)