Skip to content

Commit d73d8f8

Browse files
committed
Merge branch '3.1.x'
2 parents 7fe0086 + 1553005 commit d73d8f8

File tree

11 files changed

+51
-66
lines changed

11 files changed

+51
-66
lines changed

buildSrc/src/main/java/org/springframework/boot/build/bom/bomr/UpgradeDependencies.java

+25-24
Original file line numberDiff line numberDiff line change
@@ -108,31 +108,13 @@ private void applyUpgrades(GitHubRepository repository, List<String> issueLabels
108108
Issue existingUpgradeIssue = findExistingUpgradeIssue(existingUpgradeIssues, upgrade);
109109
try {
110110
Path modified = upgradeApplicator.apply(upgrade);
111-
int issueNumber;
112-
if (existingUpgradeIssue != null && existingUpgradeIssue.getState() == Issue.State.OPEN) {
113-
issueNumber = existingUpgradeIssue.getNumber();
114-
}
115-
else {
116-
issueNumber = repository.openIssue(title,
117-
(existingUpgradeIssue != null) ? "Supersedes #" + existingUpgradeIssue.getNumber() : "",
118-
issueLabels, milestone);
119-
if (existingUpgradeIssue != null && existingUpgradeIssue.getState() == Issue.State.CLOSED) {
120-
existingUpgradeIssue.label(Arrays.asList("type: task", "status: superseded"));
121-
}
122-
}
123-
if (existingUpgradeIssue != null) {
124-
if (existingUpgradeIssue.getState() == Issue.State.CLOSED) {
125-
System.out.println(" Issue: " + issueNumber + " - " + title + " (supersedes #"
126-
+ existingUpgradeIssue.getNumber() + " " + existingUpgradeIssue.getTitle() + ")");
127-
}
128-
else {
129-
System.out
130-
.println(" Issue: " + issueNumber + " - " + title + " (completes existing upgrade)");
131-
}
132-
}
133-
else {
134-
System.out.println(" Issue: " + issueNumber + " - " + title);
111+
int issueNumber = getOrOpenUpgradeIssue(repository, issueLabels, milestone, title,
112+
existingUpgradeIssue);
113+
if (existingUpgradeIssue != null && existingUpgradeIssue.getState() == Issue.State.CLOSED) {
114+
existingUpgradeIssue.label(Arrays.asList("type: task", "status: superseded"));
135115
}
116+
System.out.println(" Issue: " + issueNumber + " - " + title
117+
+ getExistingUpgradeIssueMessageDetails(existingUpgradeIssue));
136118
if (new ProcessBuilder().command("git", "add", modified.toFile().getAbsolutePath())
137119
.start()
138120
.waitFor() != 0) {
@@ -153,6 +135,25 @@ private void applyUpgrades(GitHubRepository repository, List<String> issueLabels
153135
}
154136
}
155137

138+
private int getOrOpenUpgradeIssue(GitHubRepository repository, List<String> issueLabels, Milestone milestone,
139+
String title, Issue existingUpgradeIssue) {
140+
if (existingUpgradeIssue != null && existingUpgradeIssue.getState() == Issue.State.OPEN) {
141+
return existingUpgradeIssue.getNumber();
142+
}
143+
String body = (existingUpgradeIssue != null) ? "Supersedes #" + existingUpgradeIssue.getNumber() : "";
144+
return repository.openIssue(title, body, issueLabels, milestone);
145+
}
146+
147+
private String getExistingUpgradeIssueMessageDetails(Issue existingUpgradeIssue) {
148+
if (existingUpgradeIssue == null) {
149+
return "";
150+
}
151+
if (existingUpgradeIssue.getState() != Issue.State.CLOSED) {
152+
return " (completes existing upgrade)";
153+
}
154+
return " (supersedes #" + existingUpgradeIssue.getNumber() + " " + existingUpgradeIssue.getTitle() + ")";
155+
}
156+
156157
private List<String> verifyLabels(GitHubRepository repository) {
157158
Set<String> availableLabels = repository.getLabels();
158159
List<String> issueLabels = this.bom.getUpgrade().getGitHub().getIssueLabels();

ci/images/releasescripts/src/main/java/io/spring/concourse/releasescripts/sonatype/ArtifactCollector.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2021 the original author or authors.
2+
* Copyright 2012-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

ci/images/releasescripts/src/main/java/io/spring/concourse/releasescripts/sonatype/SonatypeService.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2021 the original author or authors.
2+
* Copyright 2012-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/ImportAutoConfigurationImportSelector.java

+11-12
Original file line numberDiff line numberDiff line change
@@ -96,27 +96,26 @@ private Collection<String> getConfigurationsForAnnotation(Class<?> source, Annot
9696
if (classes.length > 0) {
9797
return Arrays.asList(classes);
9898
}
99-
Collection<String> factoryNames = loadFactoryNames(source);
100-
return factoryNames.stream().map((name) -> {
101-
if (name.startsWith(OPTIONAL_PREFIX)) {
102-
name = name.substring(OPTIONAL_PREFIX.length());
103-
if (!present(name)) {
104-
return null;
105-
}
106-
}
107-
return name;
108-
}).filter(Objects::nonNull).toList();
99+
return loadFactoryNames(source).stream().map(this::mapFactoryName).filter(Objects::nonNull).toList();
109100
}
110101

111-
protected Collection<String> loadFactoryNames(Class<?> source) {
112-
return ImportCandidates.load(source, getBeanClassLoader()).getCandidates();
102+
private String mapFactoryName(String name) {
103+
if (!name.startsWith(OPTIONAL_PREFIX)) {
104+
return name;
105+
}
106+
name = name.substring(OPTIONAL_PREFIX.length());
107+
return (!present(name)) ? null : name;
113108
}
114109

115110
private boolean present(String className) {
116111
String resourcePath = ClassUtils.convertClassNameToResourcePath(className) + ".class";
117112
return new ClassPathResource(resourcePath).exists();
118113
}
119114

115+
protected Collection<String> loadFactoryNames(Class<?> source) {
116+
return ImportCandidates.load(source, getBeanClassLoader()).getCandidates();
117+
}
118+
120119
@Override
121120
protected Set<String> getExclusions(AnnotationMetadata metadata, AnnotationAttributes attributes) {
122121
Set<String> exclusions = new LinkedHashSet<>();

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/JobLauncherApplicationRunner.java

+4-6
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,11 @@ public JobLauncherApplicationRunner(JobLauncher jobLauncher, JobExplorer jobExpl
113113

114114
@Override
115115
public void afterPropertiesSet() {
116-
if (this.jobs.size() > 1 && !StringUtils.hasText(this.jobName)) {
117-
throw new IllegalArgumentException("Job name must be specified in case of multiple jobs");
118-
}
116+
Assert.isTrue(this.jobs.size() <= 1 || StringUtils.hasText(this.jobName),
117+
"Job name must be specified in case of multiple jobs");
119118
if (StringUtils.hasText(this.jobName)) {
120-
if (!isLocalJob(this.jobName) && !isRegisteredJob(this.jobName)) {
121-
throw new IllegalArgumentException("No job found with name '" + this.jobName + "'");
122-
}
119+
Assert.isTrue(isLocalJob(this.jobName) || isRegisteredJob(this.jobName),
120+
() -> "No job found with name '" + this.jobName + "'");
123121
}
124122
}
125123

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/elasticsearch/ReactiveElasticsearchClientAutoConfiguration.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2022 the original author or authors.
2+
* Copyright 2012-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/SecurityProperties.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2022 the original author or authors.
2+
* Copyright 2012-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

spring-boot-project/spring-boot-docker-compose/src/test/java/org/springframework/boot/docker/compose/core/DockerCliIntegrationTests.java

+3-9
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,7 @@ void runLifecycle() throws IOException {
8989
cli.run(new ComposeStop(Duration.ofSeconds(10)));
9090
ps = cli.run(new ComposePs());
9191
assertThat(ps).isEmpty();
92-
// Run start, verify that service is there, then run down and verify they are
93-
// gone
92+
// Run start, verify service is there, then run down and verify they are gone
9493
cli.run(new ComposeStart(LogLevel.INFO));
9594
ps = cli.run(new ComposePs());
9695
assertThat(ps).hasSize(1);
@@ -116,15 +115,10 @@ private static void quietComposeDown(DockerCli cli) {
116115
private static File createComposeFile() throws IOException {
117116
File composeFile = new ClassPathResource("redis-compose.yaml", DockerCliIntegrationTests.class).getFile();
118117
File tempComposeFile = Path.of(tempDir.toString(), composeFile.getName()).toFile();
119-
String composeFileContent;
120-
try (FileReader reader = new FileReader(composeFile)) {
121-
composeFileContent = FileCopyUtils.copyToString(reader);
122-
}
118+
String composeFileContent = FileCopyUtils.copyToString(new FileReader(composeFile));
123119
composeFileContent = composeFileContent.replace("{imageName}",
124120
DockerImageNames.redis().asCanonicalNameString());
125-
try (FileWriter writer = new FileWriter(tempComposeFile)) {
126-
FileCopyUtils.copy(composeFileContent, writer);
127-
}
121+
FileCopyUtils.copy(composeFileContent, new FileWriter(tempComposeFile));
128122
return tempComposeFile;
129123
}
130124

spring-boot-project/spring-boot-docker-compose/src/test/java/org/springframework/boot/docker/compose/service/connection/test/AbstractDockerComposeIntegrationTests.java

+2-7
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,9 @@ protected final <T extends ConnectionDetails> T run(Class<T> type) {
8383
private File transformedComposeFile(File composeFile, DockerImageName imageName) {
8484
File tempComposeFile = Path.of(tempDir.toString(), composeFile.getName()).toFile();
8585
try {
86-
String composeFileContent;
87-
try (FileReader reader = new FileReader(composeFile)) {
88-
composeFileContent = FileCopyUtils.copyToString(reader);
89-
}
86+
String composeFileContent = FileCopyUtils.copyToString(new FileReader(composeFile));
9087
composeFileContent = composeFileContent.replace("{imageName}", imageName.asCanonicalNameString());
91-
try (FileWriter writer = new FileWriter(tempComposeFile)) {
92-
FileCopyUtils.copy(composeFileContent, writer);
93-
}
88+
FileCopyUtils.copy(composeFileContent, new FileWriter(tempComposeFile));
9489
}
9590
catch (IOException ex) {
9691
fail("Error transforming Docker compose file '" + composeFile + "' to '" + tempComposeFile + "': "

spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/docker/ssl/KeyStoreFactoryTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2022 the original author or authors.
2+
* Copyright 2012-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/logback/LogbackLoggingSystem.java

+1-3
Original file line numberDiff line numberDiff line change
@@ -269,9 +269,7 @@ private void reportConfigurationErrorsIfNecessary(LoggerContext loggerContext) {
269269
}
270270
IllegalStateException ex = new IllegalStateException(
271271
String.format("Logback configuration error detected: %n%s", errors));
272-
for (Throwable suppressedException : suppressedExceptions) {
273-
ex.addSuppressed(suppressedException);
274-
}
272+
suppressedExceptions.forEach(ex::addSuppressed);
275273
throw ex;
276274
}
277275

0 commit comments

Comments
 (0)