From e10ac76761206c679dd4470c516937b6922edd25 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Wed, 20 Sep 2023 15:43:03 -0700 Subject: [PATCH 1/3] Polish --- .../bomr/StandardLibraryUpdateResolver.java | 12 +--- .../build/bom/bomr/UpgradeDependencies.java | 60 +++++++++---------- .../platform/socket/DomainSocket.java | 2 +- 3 files changed, 31 insertions(+), 43 deletions(-) diff --git a/buildSrc/src/main/java/org/springframework/boot/build/bom/bomr/StandardLibraryUpdateResolver.java b/buildSrc/src/main/java/org/springframework/boot/build/bom/bomr/StandardLibraryUpdateResolver.java index 1eddf80d758..a9a403164e7 100644 --- a/buildSrc/src/main/java/org/springframework/boot/build/bom/bomr/StandardLibraryUpdateResolver.java +++ b/buildSrc/src/main/java/org/springframework/boot/build/bom/bomr/StandardLibraryUpdateResolver.java @@ -51,16 +51,8 @@ class StandardLibraryUpdateResolver implements LibraryUpdateResolver { StandardLibraryUpdateResolver(VersionResolver versionResolver, List> predicates) { this.versionResolver = versionResolver; - BiPredicate predicate = null; - for (BiPredicate p : predicates) { - if (predicate == null) { - predicate = p; - } - else { - predicate = predicate.and(p); - } - } - this.predicate = predicate; + this.predicate = (library, dependencyVersion) -> predicates.stream() + .allMatch((predicate) -> predicate.test(library, dependencyVersion)); } @Override diff --git a/buildSrc/src/main/java/org/springframework/boot/build/bom/bomr/UpgradeDependencies.java b/buildSrc/src/main/java/org/springframework/boot/build/bom/bomr/UpgradeDependencies.java index 96a4eecb131..b4c9c7e2180 100644 --- a/buildSrc/src/main/java/org/springframework/boot/build/bom/bomr/UpgradeDependencies.java +++ b/buildSrc/src/main/java/org/springframework/boot/build/bom/bomr/UpgradeDependencies.java @@ -35,6 +35,7 @@ import java.util.stream.Collectors; import javax.inject.Inject; import org.apache.maven.artifact.versioning.DefaultArtifactVersion; +import org.apache.maven.artifact.versioning.VersionRange; import org.gradle.api.DefaultTask; import org.gradle.api.InvalidUserDataException; import org.gradle.api.internal.tasks.userinput.UserInputHandler; @@ -228,42 +229,37 @@ public abstract class UpgradeDependencies extends DefaultTask { } protected List> determineUpdatePredicates(Milestone milestone) { - BiPredicate compilesWithUpgradePolicy = (library, - candidate) -> this.bom.getUpgrade().getPolicy().test(candidate, library.getVersion().getVersion()); - BiPredicate isAnUpgrade = (library, - candidate) -> library.getVersion().getVersion().isUpgrade(candidate, this.movingToSnapshots); - BiPredicate isPermitted = (library, candidate) -> { - for (ProhibitedVersion prohibitedVersion : library.getProhibitedVersions()) { - String candidateString = candidate.toString(); - if (prohibitedVersion.getRange() != null - && prohibitedVersion.getRange().containsVersion(new DefaultArtifactVersion(candidateString))) { - return false; - } - for (String startsWith : prohibitedVersion.getStartsWith()) { - if (candidateString.startsWith(startsWith)) { - return false; - } - } - for (String endsWith : prohibitedVersion.getEndsWith()) { - if (candidateString.endsWith(endsWith)) { - return false; - } - } - for (String contains : prohibitedVersion.getContains()) { - if (candidateString.contains(contains)) { - return false; - } - } - } - return true; - }; List> updatePredicates = new ArrayList<>(); - updatePredicates.add(compilesWithUpgradePolicy); - updatePredicates.add(isAnUpgrade); - updatePredicates.add(isPermitted); + updatePredicates.add(this::compilesWithUpgradePolicy); + updatePredicates.add(this::isAnUpgrade); + updatePredicates.add(this::isNotProhibited); return updatePredicates; } + private boolean compilesWithUpgradePolicy(Library library, DependencyVersion candidate) { + return this.bom.getUpgrade().getPolicy().test(candidate, library.getVersion().getVersion()); + } + + private boolean isAnUpgrade(Library library, DependencyVersion candidate) { + return library.getVersion().getVersion().isUpgrade(candidate, this.movingToSnapshots); + } + + private boolean isNotProhibited(Library library, DependencyVersion candidate) { + return !library.getProhibitedVersions() + .stream() + .anyMatch((prohibited) -> isProhibited(prohibited, candidate.toString())); + } + + private boolean isProhibited(ProhibitedVersion prohibited, String candidate) { + boolean result = false; + VersionRange range = prohibited.getRange(); + result = result || (range != null && range.containsVersion(new DefaultArtifactVersion(candidate))); + result = result || prohibited.getStartsWith().stream().anyMatch(candidate::startsWith); + result = result || prohibited.getStartsWith().stream().anyMatch(candidate::endsWith); + result = result || prohibited.getStartsWith().stream().anyMatch(candidate::contains); + return result; + } + private List matchingLibraries() { List matchingLibraries = this.bom.getLibraries() .stream() diff --git a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/socket/DomainSocket.java b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/socket/DomainSocket.java index 1c4e8eb2ef9..7d885efb540 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/socket/DomainSocket.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/socket/DomainSocket.java @@ -74,7 +74,7 @@ public abstract class DomainSocket extends AbstractSocket { return new FileDescriptor(handle, this::close); } catch (RuntimeException ex) { - this.close(handle); + close(handle); throw ex; } } From b83e7b42bbdd5fd912a50af52c8cfd00e8f31d29 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Wed, 20 Sep 2023 16:05:44 -0700 Subject: [PATCH 2/3] Update copyright year of changed files --- .../java/org/springframework/boot/build/bom/UpgradePolicy.java | 2 +- .../springframework/boot/build/bom/bomr/ReleaseSchedule.java | 2 +- .../springframework/boot/build/bom/bomr/github/Milestone.java | 2 +- .../boot/build/bom/bomr/version/AbstractDependencyVersion.java | 2 +- .../bom/bomr/version/CalendarVersionDependencyVersion.java | 2 +- .../build/bom/bomr/version/UnstructuredDependencyVersion.java | 2 +- .../boot/build/bom/bomr/ReleaseScheduleTests.java | 2 +- .../bom/bomr/version/CalendarVersionDependencyVersionTests.java | 2 +- .../build/bom/bomr/version/DependencyVersionUpgradeTests.java | 2 +- .../boot/autoconfigure/jms/artemis/ArtemisProperties.java | 2 +- .../web/embedded/NettyWebServerFactoryCustomizerTests.java | 2 +- .../boot/test/autoconfigure/jdbc/ExampleRepository.java | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) diff --git a/buildSrc/src/main/java/org/springframework/boot/build/bom/UpgradePolicy.java b/buildSrc/src/main/java/org/springframework/boot/build/bom/UpgradePolicy.java index af2341a8c1a..e9d72393965 100644 --- a/buildSrc/src/main/java/org/springframework/boot/build/bom/UpgradePolicy.java +++ b/buildSrc/src/main/java/org/springframework/boot/build/bom/UpgradePolicy.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/buildSrc/src/main/java/org/springframework/boot/build/bom/bomr/ReleaseSchedule.java b/buildSrc/src/main/java/org/springframework/boot/build/bom/bomr/ReleaseSchedule.java index 28d827867cd..c32518b4624 100644 --- a/buildSrc/src/main/java/org/springframework/boot/build/bom/bomr/ReleaseSchedule.java +++ b/buildSrc/src/main/java/org/springframework/boot/build/bom/bomr/ReleaseSchedule.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 the original author or authors. + * Copyright 2023-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/buildSrc/src/main/java/org/springframework/boot/build/bom/bomr/github/Milestone.java b/buildSrc/src/main/java/org/springframework/boot/build/bom/bomr/github/Milestone.java index 7a1ce8ae266..38d3f1dd5e2 100644 --- a/buildSrc/src/main/java/org/springframework/boot/build/bom/bomr/github/Milestone.java +++ b/buildSrc/src/main/java/org/springframework/boot/build/bom/bomr/github/Milestone.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/buildSrc/src/main/java/org/springframework/boot/build/bom/bomr/version/AbstractDependencyVersion.java b/buildSrc/src/main/java/org/springframework/boot/build/bom/bomr/version/AbstractDependencyVersion.java index 89860306c16..64eb84d5d2c 100644 --- a/buildSrc/src/main/java/org/springframework/boot/build/bom/bomr/version/AbstractDependencyVersion.java +++ b/buildSrc/src/main/java/org/springframework/boot/build/bom/bomr/version/AbstractDependencyVersion.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/buildSrc/src/main/java/org/springframework/boot/build/bom/bomr/version/CalendarVersionDependencyVersion.java b/buildSrc/src/main/java/org/springframework/boot/build/bom/bomr/version/CalendarVersionDependencyVersion.java index 59c685fd23f..475e2149f90 100644 --- a/buildSrc/src/main/java/org/springframework/boot/build/bom/bomr/version/CalendarVersionDependencyVersion.java +++ b/buildSrc/src/main/java/org/springframework/boot/build/bom/bomr/version/CalendarVersionDependencyVersion.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/buildSrc/src/main/java/org/springframework/boot/build/bom/bomr/version/UnstructuredDependencyVersion.java b/buildSrc/src/main/java/org/springframework/boot/build/bom/bomr/version/UnstructuredDependencyVersion.java index cdd44f9cbcc..5799225958b 100644 --- a/buildSrc/src/main/java/org/springframework/boot/build/bom/bomr/version/UnstructuredDependencyVersion.java +++ b/buildSrc/src/main/java/org/springframework/boot/build/bom/bomr/version/UnstructuredDependencyVersion.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/buildSrc/src/test/java/org/springframework/boot/build/bom/bomr/ReleaseScheduleTests.java b/buildSrc/src/test/java/org/springframework/boot/build/bom/bomr/ReleaseScheduleTests.java index 3931221ffaf..f4718e62f07 100644 --- a/buildSrc/src/test/java/org/springframework/boot/build/bom/bomr/ReleaseScheduleTests.java +++ b/buildSrc/src/test/java/org/springframework/boot/build/bom/bomr/ReleaseScheduleTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 the original author or authors. + * Copyright 2023-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/buildSrc/src/test/java/org/springframework/boot/build/bom/bomr/version/CalendarVersionDependencyVersionTests.java b/buildSrc/src/test/java/org/springframework/boot/build/bom/bomr/version/CalendarVersionDependencyVersionTests.java index 023b64b0bd3..08ebb7dbf98 100644 --- a/buildSrc/src/test/java/org/springframework/boot/build/bom/bomr/version/CalendarVersionDependencyVersionTests.java +++ b/buildSrc/src/test/java/org/springframework/boot/build/bom/bomr/version/CalendarVersionDependencyVersionTests.java @@ -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"); * you may not use this file except in compliance with the License. diff --git a/buildSrc/src/test/java/org/springframework/boot/build/bom/bomr/version/DependencyVersionUpgradeTests.java b/buildSrc/src/test/java/org/springframework/boot/build/bom/bomr/version/DependencyVersionUpgradeTests.java index f51b9eea9e7..7220de730d0 100644 --- a/buildSrc/src/test/java/org/springframework/boot/build/bom/bomr/version/DependencyVersionUpgradeTests.java +++ b/buildSrc/src/test/java/org/springframework/boot/build/bom/bomr/version/DependencyVersionUpgradeTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 the original author or authors. + * Copyright 2023-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/artemis/ArtemisProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/artemis/ArtemisProperties.java index e7db6ff2bae..15325c1c276 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/artemis/ArtemisProperties.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/artemis/ArtemisProperties.java @@ -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"); * you may not use this file except in compliance with the License. diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/NettyWebServerFactoryCustomizerTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/NettyWebServerFactoryCustomizerTests.java index 65795b60bde..b65a150a330 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/NettyWebServerFactoryCustomizerTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/NettyWebServerFactoryCustomizerTests.java @@ -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"); * you may not use this file except in compliance with the License. diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jdbc/ExampleRepository.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jdbc/ExampleRepository.java index 65de4960730..4286cf9ca10 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jdbc/ExampleRepository.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/jdbc/ExampleRepository.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. From 78c3512e32ab776c9174dafed2e3887a043399eb Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Wed, 20 Sep 2023 17:11:54 -0700 Subject: [PATCH 3/3] Polish --- .../actuate/autoconfigure/tracing/BraveAutoConfiguration.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/tracing/BraveAutoConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/tracing/BraveAutoConfiguration.java index 4a3291a8871..b4c8deb1d1b 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/tracing/BraveAutoConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/tracing/BraveAutoConfiguration.java @@ -207,10 +207,12 @@ public class BraveAutoConfiguration { @SuppressWarnings("deprecation") private Factory createThrowAwayFactory() { return new Factory() { + @Override public Propagation create(KeyFactory keyFactory) { return null; } + }; }