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/StandardLibraryUpdateResolver.java b/buildSrc/src/main/java/org/springframework/boot/build/bom/bomr/StandardLibraryUpdateResolver.java index 3e39206fc3a..5bbdd90a62f 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 @@ -49,16 +49,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 2110e762b81..332dad87055 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 @@ -34,6 +34,7 @@ import java.util.regex.Pattern; 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; @@ -227,42 +228,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().filter(this::eligible).toList(); if (matchingLibraries.isEmpty()) { 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 5a4934f8755..4d17ceefc81 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-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/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-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 c9ae2bd491b..3fde9bb60b7 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 @@ -226,10 +226,12 @@ public class BraveAutoConfiguration { @SuppressWarnings("deprecation") private Factory createThrowAwayFactory() { return new Factory() { + @Override public Propagation create(KeyFactory keyFactory) { return null; } + }; } 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-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 92ecd0f1be1..346a524e7de 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-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/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; } }