Skip to content

Commit 4d0cce7

Browse files
committed
Prevent IOException in CheckAutoConfigurationClasses
This commit ensures that before walking a source root, the Gradle plugin checks that it exists. This situation can only happen when a Gradle plugin adds new roots to SourceSets, but there are no sources in them. Fixes gh-47142
1 parent 450eb48 commit 4d0cce7

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

buildSrc/src/main/java/org/springframework/boot/build/autoconfigure/CheckAutoConfigurationClasses.java

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -136,15 +136,17 @@ void execute() {
136136
private List<File> classFiles() {
137137
List<File> classFiles = new ArrayList<>();
138138
for (File root : this.classpath.getFiles()) {
139-
try (Stream<Path> files = Files.walk(root.toPath())) {
140-
files.forEach((file) -> {
141-
if (Files.isRegularFile(file) && file.getFileName().toString().endsWith(".class")) {
142-
classFiles.add(file.toFile());
143-
}
144-
});
145-
}
146-
catch (IOException ex) {
147-
throw new UncheckedIOException(ex);
139+
if (root.exists()) {
140+
try (Stream<Path> files = Files.walk(root.toPath())) {
141+
files.forEach((file) -> {
142+
if (Files.isRegularFile(file) && file.getFileName().toString().endsWith(".class")) {
143+
classFiles.add(file.toFile());
144+
}
145+
});
146+
}
147+
catch (IOException ex) {
148+
throw new UncheckedIOException(ex);
149+
}
148150
}
149151
}
150152
return classFiles;

0 commit comments

Comments
 (0)