Merge branch '3.1.x'

This commit is contained in:
Phillip Webb 2023-08-13 19:15:56 -07:00
commit d73d8f8e4f
11 changed files with 51 additions and 66 deletions

View File

@ -108,31 +108,13 @@ public abstract class UpgradeDependencies extends DefaultTask {
Issue existingUpgradeIssue = findExistingUpgradeIssue(existingUpgradeIssues, upgrade); Issue existingUpgradeIssue = findExistingUpgradeIssue(existingUpgradeIssues, upgrade);
try { try {
Path modified = upgradeApplicator.apply(upgrade); Path modified = upgradeApplicator.apply(upgrade);
int issueNumber; int issueNumber = getOrOpenUpgradeIssue(repository, issueLabels, milestone, title,
if (existingUpgradeIssue != null && existingUpgradeIssue.getState() == Issue.State.OPEN) { existingUpgradeIssue);
issueNumber = existingUpgradeIssue.getNumber(); if (existingUpgradeIssue != null && existingUpgradeIssue.getState() == Issue.State.CLOSED) {
} existingUpgradeIssue.label(Arrays.asList("type: task", "status: superseded"));
else {
issueNumber = repository.openIssue(title,
(existingUpgradeIssue != null) ? "Supersedes #" + existingUpgradeIssue.getNumber() : "",
issueLabels, milestone);
if (existingUpgradeIssue != null && existingUpgradeIssue.getState() == Issue.State.CLOSED) {
existingUpgradeIssue.label(Arrays.asList("type: task", "status: superseded"));
}
}
if (existingUpgradeIssue != null) {
if (existingUpgradeIssue.getState() == Issue.State.CLOSED) {
System.out.println(" Issue: " + issueNumber + " - " + title + " (supersedes #"
+ existingUpgradeIssue.getNumber() + " " + existingUpgradeIssue.getTitle() + ")");
}
else {
System.out
.println(" Issue: " + issueNumber + " - " + title + " (completes existing upgrade)");
}
}
else {
System.out.println(" Issue: " + issueNumber + " - " + title);
} }
System.out.println(" Issue: " + issueNumber + " - " + title
+ getExistingUpgradeIssueMessageDetails(existingUpgradeIssue));
if (new ProcessBuilder().command("git", "add", modified.toFile().getAbsolutePath()) if (new ProcessBuilder().command("git", "add", modified.toFile().getAbsolutePath())
.start() .start()
.waitFor() != 0) { .waitFor() != 0) {
@ -153,6 +135,25 @@ public abstract class UpgradeDependencies extends DefaultTask {
} }
} }
private int getOrOpenUpgradeIssue(GitHubRepository repository, List<String> issueLabels, Milestone milestone,
String title, Issue existingUpgradeIssue) {
if (existingUpgradeIssue != null && existingUpgradeIssue.getState() == Issue.State.OPEN) {
return existingUpgradeIssue.getNumber();
}
String body = (existingUpgradeIssue != null) ? "Supersedes #" + existingUpgradeIssue.getNumber() : "";
return repository.openIssue(title, body, issueLabels, milestone);
}
private String getExistingUpgradeIssueMessageDetails(Issue existingUpgradeIssue) {
if (existingUpgradeIssue == null) {
return "";
}
if (existingUpgradeIssue.getState() != Issue.State.CLOSED) {
return " (completes existing upgrade)";
}
return " (supersedes #" + existingUpgradeIssue.getNumber() + " " + existingUpgradeIssue.getTitle() + ")";
}
private List<String> verifyLabels(GitHubRepository repository) { private List<String> verifyLabels(GitHubRepository repository) {
Set<String> availableLabels = repository.getLabels(); Set<String> availableLabels = repository.getLabels();
List<String> issueLabels = this.bom.getUpgrade().getGitHub().getIssueLabels(); List<String> issueLabels = this.bom.getUpgrade().getGitHub().getIssueLabels();

View File

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

View File

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

View File

@ -96,20 +96,15 @@ class ImportAutoConfigurationImportSelector extends AutoConfigurationImportSelec
if (classes.length > 0) { if (classes.length > 0) {
return Arrays.asList(classes); return Arrays.asList(classes);
} }
Collection<String> factoryNames = loadFactoryNames(source); return loadFactoryNames(source).stream().map(this::mapFactoryName).filter(Objects::nonNull).toList();
return factoryNames.stream().map((name) -> {
if (name.startsWith(OPTIONAL_PREFIX)) {
name = name.substring(OPTIONAL_PREFIX.length());
if (!present(name)) {
return null;
}
}
return name;
}).filter(Objects::nonNull).toList();
} }
protected Collection<String> loadFactoryNames(Class<?> source) { private String mapFactoryName(String name) {
return ImportCandidates.load(source, getBeanClassLoader()).getCandidates(); if (!name.startsWith(OPTIONAL_PREFIX)) {
return name;
}
name = name.substring(OPTIONAL_PREFIX.length());
return (!present(name)) ? null : name;
} }
private boolean present(String className) { private boolean present(String className) {
@ -117,6 +112,10 @@ class ImportAutoConfigurationImportSelector extends AutoConfigurationImportSelec
return new ClassPathResource(resourcePath).exists(); return new ClassPathResource(resourcePath).exists();
} }
protected Collection<String> loadFactoryNames(Class<?> source) {
return ImportCandidates.load(source, getBeanClassLoader()).getCandidates();
}
@Override @Override
protected Set<String> getExclusions(AnnotationMetadata metadata, AnnotationAttributes attributes) { protected Set<String> getExclusions(AnnotationMetadata metadata, AnnotationAttributes attributes) {
Set<String> exclusions = new LinkedHashSet<>(); Set<String> exclusions = new LinkedHashSet<>();

View File

@ -113,13 +113,11 @@ public class JobLauncherApplicationRunner
@Override @Override
public void afterPropertiesSet() { public void afterPropertiesSet() {
if (this.jobs.size() > 1 && !StringUtils.hasText(this.jobName)) { Assert.isTrue(this.jobs.size() <= 1 || StringUtils.hasText(this.jobName),
throw new IllegalArgumentException("Job name must be specified in case of multiple jobs"); "Job name must be specified in case of multiple jobs");
}
if (StringUtils.hasText(this.jobName)) { if (StringUtils.hasText(this.jobName)) {
if (!isLocalJob(this.jobName) && !isRegisteredJob(this.jobName)) { Assert.isTrue(isLocalJob(this.jobName) || isRegisteredJob(this.jobName),
throw new IllegalArgumentException("No job found with name '" + this.jobName + "'"); () -> "No job found with name '" + this.jobName + "'");
}
} }
} }

View File

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

View File

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

View File

@ -89,8 +89,7 @@ class DockerCliIntegrationTests {
cli.run(new ComposeStop(Duration.ofSeconds(10))); cli.run(new ComposeStop(Duration.ofSeconds(10)));
ps = cli.run(new ComposePs()); ps = cli.run(new ComposePs());
assertThat(ps).isEmpty(); assertThat(ps).isEmpty();
// Run start, verify that service is there, then run down and verify they are // Run start, verify service is there, then run down and verify they are gone
// gone
cli.run(new ComposeStart(LogLevel.INFO)); cli.run(new ComposeStart(LogLevel.INFO));
ps = cli.run(new ComposePs()); ps = cli.run(new ComposePs());
assertThat(ps).hasSize(1); assertThat(ps).hasSize(1);
@ -116,15 +115,10 @@ class DockerCliIntegrationTests {
private static File createComposeFile() throws IOException { private static File createComposeFile() throws IOException {
File composeFile = new ClassPathResource("redis-compose.yaml", DockerCliIntegrationTests.class).getFile(); File composeFile = new ClassPathResource("redis-compose.yaml", DockerCliIntegrationTests.class).getFile();
File tempComposeFile = Path.of(tempDir.toString(), composeFile.getName()).toFile(); File tempComposeFile = Path.of(tempDir.toString(), composeFile.getName()).toFile();
String composeFileContent; String composeFileContent = FileCopyUtils.copyToString(new FileReader(composeFile));
try (FileReader reader = new FileReader(composeFile)) {
composeFileContent = FileCopyUtils.copyToString(reader);
}
composeFileContent = composeFileContent.replace("{imageName}", composeFileContent = composeFileContent.replace("{imageName}",
DockerImageNames.redis().asCanonicalNameString()); DockerImageNames.redis().asCanonicalNameString());
try (FileWriter writer = new FileWriter(tempComposeFile)) { FileCopyUtils.copy(composeFileContent, new FileWriter(tempComposeFile));
FileCopyUtils.copy(composeFileContent, writer);
}
return tempComposeFile; return tempComposeFile;
} }

View File

@ -83,14 +83,9 @@ public abstract class AbstractDockerComposeIntegrationTests {
private File transformedComposeFile(File composeFile, DockerImageName imageName) { private File transformedComposeFile(File composeFile, DockerImageName imageName) {
File tempComposeFile = Path.of(tempDir.toString(), composeFile.getName()).toFile(); File tempComposeFile = Path.of(tempDir.toString(), composeFile.getName()).toFile();
try { try {
String composeFileContent; String composeFileContent = FileCopyUtils.copyToString(new FileReader(composeFile));
try (FileReader reader = new FileReader(composeFile)) {
composeFileContent = FileCopyUtils.copyToString(reader);
}
composeFileContent = composeFileContent.replace("{imageName}", imageName.asCanonicalNameString()); composeFileContent = composeFileContent.replace("{imageName}", imageName.asCanonicalNameString());
try (FileWriter writer = new FileWriter(tempComposeFile)) { FileCopyUtils.copy(composeFileContent, new FileWriter(tempComposeFile));
FileCopyUtils.copy(composeFileContent, writer);
}
} }
catch (IOException ex) { catch (IOException ex) {
fail("Error transforming Docker compose file '" + composeFile + "' to '" + tempComposeFile + "': " fail("Error transforming Docker compose file '" + composeFile + "' to '" + tempComposeFile + "': "

View File

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

View File

@ -269,9 +269,7 @@ public class LogbackLoggingSystem extends AbstractLoggingSystem implements BeanF
} }
IllegalStateException ex = new IllegalStateException( IllegalStateException ex = new IllegalStateException(
String.format("Logback configuration error detected: %n%s", errors)); String.format("Logback configuration error detected: %n%s", errors));
for (Throwable suppressedException : suppressedExceptions) { suppressedExceptions.forEach(ex::addSuppressed);
ex.addSuppressed(suppressedException);
}
throw ex; throw ex;
} }