Skip to content

Commit 896b576

Browse files
committed
Polish
1 parent 2d6eb66 commit 896b576

File tree

3 files changed

+26
-28
lines changed

3 files changed

+26
-28
lines changed

Diff for: buildSrc/src/main/java/org/springframework/boot/build/springframework/CheckFactoriesFile.java

+24-23
Original file line numberDiff line numberDiff line change
@@ -96,31 +96,17 @@ void execute() {
9696
}
9797

9898
private void check(File factoriesFile) {
99-
Properties factories = load(factoriesFile);
99+
Properties properties = load(factoriesFile);
100100
Map<String, List<String>> problems = new LinkedHashMap<>();
101-
for (String key : factories.stringPropertyNames()) {
102-
List<String> values = Arrays
103-
.asList(StringUtils.commaDelimitedListToStringArray(factories.getProperty(key)));
104-
for (String value : values) {
105-
boolean found = find(value);
106-
if (!found) {
107-
List<String> problemsForKey = problems.computeIfAbsent(key, (k) -> new ArrayList<>());
108-
String binaryName = binaryNameOf(value);
109-
found = find(binaryName);
110-
if (found) {
111-
problemsForKey
112-
.add("'%s' should be listed using its binary name '%s'".formatted(value, binaryName));
113-
}
114-
else {
115-
problemsForKey.add("'%s' was not found".formatted(value));
116-
}
117-
}
118-
}
119-
List<String> sortedValues = new ArrayList<>(values);
101+
for (String name : properties.stringPropertyNames()) {
102+
String value = properties.getProperty(name);
103+
List<String> classNames = Arrays.asList(StringUtils.commaDelimitedListToStringArray(value));
104+
collectProblems(problems, name, classNames);
105+
List<String> sortedValues = new ArrayList<>(classNames);
120106
Collections.sort(sortedValues);
121-
if (!sortedValues.equals(values)) {
122-
List<String> problemsForKey = problems.computeIfAbsent(key, (k) -> new ArrayList<>());
123-
problemsForKey.add("Entries should be sorted alphabetically");
107+
if (!sortedValues.equals(classNames)) {
108+
List<String> problemsForClassName = problems.computeIfAbsent(name, (k) -> new ArrayList<>());
109+
problemsForClassName.add("Entries should be sorted alphabetically");
124110
}
125111
}
126112
File outputFile = getOutputDirectory().file("failure-report.txt").get().getAsFile();
@@ -130,6 +116,21 @@ private void check(File factoriesFile) {
130116
}
131117
}
132118

119+
private void collectProblems(Map<String, List<String>> problems, String key, List<String> classNames) {
120+
for (String className : classNames) {
121+
if (!find(className)) {
122+
addNoFoundProblem(className, problems.computeIfAbsent(key, (k) -> new ArrayList<>()));
123+
}
124+
}
125+
}
126+
127+
private void addNoFoundProblem(String className, List<String> problemsForClassName) {
128+
String binaryName = binaryNameOf(className);
129+
boolean foundBinaryForm = find(binaryName);
130+
problemsForClassName.add(!foundBinaryForm ? "'%s' was not found".formatted(className)
131+
: "'%s' should be listed using its binary name '%s'".formatted(className, binaryName));
132+
}
133+
133134
private boolean find(String className) {
134135
for (File root : this.classpath.getFiles()) {
135136
String classFilePath = className.replace(".", "/") + ".class";

Diff for: spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/docker/transport/HttpClientTransport.java

+1-4
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,7 @@ private byte[] readContent(ClassicHttpResponse response) throws IOException {
167167
return null;
168168
}
169169
try (InputStream stream = entity.getContent()) {
170-
if (stream == null) {
171-
return null;
172-
}
173-
return stream.readAllBytes();
170+
return (stream != null) ? stream.readAllBytes() : null;
174171
}
175172
}
176173

Diff for: spring-boot-project/spring-boot/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ dependencies {
9696
optional("org.yaml:snakeyaml")
9797
optional("org.jetbrains.kotlin:kotlin-reflect")
9898
optional("org.jetbrains.kotlin:kotlin-stdlib")
99-
99+
100100
testFixturesCompileOnly("jakarta.servlet:jakarta.servlet-api")
101101
testFixturesCompileOnly("org.mockito:mockito-core")
102102
testFixturesCompileOnly("org.springframework:spring-web")

0 commit comments

Comments
 (0)