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 1eddf80d7586..a9a403164e77 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 96a4eecb1316..b4c9c7e21803 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 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 @@ private List resolveUpgrades(Milestone milestone) { } 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 1c4e8eb2ef91..7d885efb5409 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 @@ private FileDescriptor open(String path) { return new FileDescriptor(handle, this::close); } catch (RuntimeException ex) { - this.close(handle); + close(handle); throw ex; } }