diff --git a/buildSrc/src/main/java/org/springframework/boot/build/springframework/CheckFactoriesFile.java b/buildSrc/src/main/java/org/springframework/boot/build/springframework/CheckFactoriesFile.java index 766f443aea7..9c4227fd1b5 100644 --- a/buildSrc/src/main/java/org/springframework/boot/build/springframework/CheckFactoriesFile.java +++ b/buildSrc/src/main/java/org/springframework/boot/build/springframework/CheckFactoriesFile.java @@ -96,31 +96,17 @@ public abstract class CheckFactoriesFile extends DefaultTask { } private void check(File factoriesFile) { - Properties factories = load(factoriesFile); + Properties properties = load(factoriesFile); Map> problems = new LinkedHashMap<>(); - for (String key : factories.stringPropertyNames()) { - List values = Arrays - .asList(StringUtils.commaDelimitedListToStringArray(factories.getProperty(key))); - for (String value : values) { - boolean found = find(value); - if (!found) { - List problemsForKey = problems.computeIfAbsent(key, (k) -> new ArrayList<>()); - String binaryName = binaryNameOf(value); - found = find(binaryName); - if (found) { - problemsForKey - .add("'%s' should be listed using its binary name '%s'".formatted(value, binaryName)); - } - else { - problemsForKey.add("'%s' was not found".formatted(value)); - } - } - } - List sortedValues = new ArrayList<>(values); + for (String name : properties.stringPropertyNames()) { + String value = properties.getProperty(name); + List classNames = Arrays.asList(StringUtils.commaDelimitedListToStringArray(value)); + collectProblems(problems, name, classNames); + List sortedValues = new ArrayList<>(classNames); Collections.sort(sortedValues); - if (!sortedValues.equals(values)) { - List problemsForKey = problems.computeIfAbsent(key, (k) -> new ArrayList<>()); - problemsForKey.add("Entries should be sorted alphabetically"); + if (!sortedValues.equals(classNames)) { + List problemsForClassName = problems.computeIfAbsent(name, (k) -> new ArrayList<>()); + problemsForClassName.add("Entries should be sorted alphabetically"); } } File outputFile = getOutputDirectory().file("failure-report.txt").get().getAsFile(); @@ -130,6 +116,21 @@ public abstract class CheckFactoriesFile extends DefaultTask { } } + private void collectProblems(Map> problems, String key, List classNames) { + for (String className : classNames) { + if (!find(className)) { + addNoFoundProblem(className, problems.computeIfAbsent(key, (k) -> new ArrayList<>())); + } + } + } + + private void addNoFoundProblem(String className, List problemsForClassName) { + String binaryName = binaryNameOf(className); + boolean foundBinaryForm = find(binaryName); + problemsForClassName.add(!foundBinaryForm ? "'%s' was not found".formatted(className) + : "'%s' should be listed using its binary name '%s'".formatted(className, binaryName)); + } + private boolean find(String className) { for (File root : this.classpath.getFiles()) { String classFilePath = className.replace(".", "/") + ".class"; diff --git a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/docker/transport/HttpClientTransport.java b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/docker/transport/HttpClientTransport.java index 551aea0f946..3546ab834f2 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/docker/transport/HttpClientTransport.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/docker/transport/HttpClientTransport.java @@ -179,10 +179,7 @@ abstract class HttpClientTransport implements HttpTransport { return null; } try (InputStream stream = entity.getContent()) { - if (stream == null) { - return null; - } - return stream.readAllBytes(); + return (stream != null) ? stream.readAllBytes() : null; } }