From f8f549cc72de4c42f376af379bed5876207529e3 Mon Sep 17 00:00:00 2001 From: spencergibb Date: Thu, 8 Jul 2021 16:44:45 -0400 Subject: [PATCH] Updated SpringBootVersionVerifier to require boot 2.6 --- pom.xml | 10 ++++++ .../CompatibilityVerifierProperties.java | 2 +- .../SpringBootVersionVerifier.java | 34 +++---------------- .../SpringBootDependencyTests.java | 20 +++++------ 4 files changed, 26 insertions(+), 40 deletions(-) diff --git a/pom.xml b/pom.xml index 94a1de08..c89bdb63 100644 --- a/pom.xml +++ b/pom.xml @@ -155,6 +155,16 @@ org.springframework.security.oauth.boot spring-security-oauth2-autoconfigure ${spring-security-oauth2-autoconfigure.version} + + + org.springframework.boot + spring-boot + + + org.springframework.boot + spring-boot-autoconfigure + + diff --git a/spring-cloud-commons/src/main/java/org/springframework/cloud/configuration/CompatibilityVerifierProperties.java b/spring-cloud-commons/src/main/java/org/springframework/cloud/configuration/CompatibilityVerifierProperties.java index 21d0fb75..b12c49c1 100644 --- a/spring-cloud-commons/src/main/java/org/springframework/cloud/configuration/CompatibilityVerifierProperties.java +++ b/spring-cloud-commons/src/main/java/org/springframework/cloud/configuration/CompatibilityVerifierProperties.java @@ -37,7 +37,7 @@ public class CompatibilityVerifierProperties { * the patch version if you don't want to specify a concrete value. Example: * {@code 3.4.x} */ - private List compatibleBootVersions = Arrays.asList("2.4.x", "2.5.x"); + private List compatibleBootVersions = Arrays.asList("2.6.x"); public boolean isEnabled() { return this.enabled; diff --git a/spring-cloud-commons/src/main/java/org/springframework/cloud/configuration/SpringBootVersionVerifier.java b/spring-cloud-commons/src/main/java/org/springframework/cloud/configuration/SpringBootVersionVerifier.java index c4a78f65..fc2fddbd 100644 --- a/spring-cloud-commons/src/main/java/org/springframework/cloud/configuration/SpringBootVersionVerifier.java +++ b/spring-cloud-commons/src/main/java/org/springframework/cloud/configuration/SpringBootVersionVerifier.java @@ -35,8 +35,7 @@ class SpringBootVersionVerifier implements CompatibilityVerifier { final Map ACCEPTED_VERSIONS = new HashMap() { { - this.put("2.4", is2_4()); - this.put("2.5", is2_5()); + this.put("2.6", is2_6()); } }; @@ -71,42 +70,19 @@ class SpringBootVersionVerifier implements CompatibilityVerifier { return SpringBootVersion.getVersion(); } - CompatibilityPredicate is2_4() { + CompatibilityPredicate is2_6() { return new CompatibilityPredicate() { @Override public String toString() { - return "Predicate for Boot 2.4"; + return "Predicate for Boot 2.6"; } @Override public boolean isCompatible() { try { - // since 2.4 - Class.forName("org.springframework.boot.Bootstrapper"); - return true; - } - catch (ClassNotFoundException e) { - return false; - } - - } - }; - } - - CompatibilityPredicate is2_5() { - return new CompatibilityPredicate() { - - @Override - public String toString() { - return "Predicate for Boot 2.5"; - } - - @Override - public boolean isCompatible() { - try { - // since 2.4 - Class.forName("org.springframework.boot.context.properties.bind.Bindable.BindRestriction"); + // since 2.6 + Class.forName("org.springframework.boot.autoconfigure.data.redis.ClientResourcesBuilderCustomizer"); return true; } catch (ClassNotFoundException e) { diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/configuration/SpringBootDependencyTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/configuration/SpringBootDependencyTests.java index c8f489a4..d3161338 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/configuration/SpringBootDependencyTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/configuration/SpringBootDependencyTests.java @@ -176,14 +176,14 @@ public class SpringBootDependencyTests { @Test public void should_match_against_current_manifest() { try { - verifyCurrentVersionFromManifest("2.4"); - verifyCurrentVersionFromManifest("2.4.x"); + verifyCurrentVersionFromManifest("2.6"); + verifyCurrentVersionFromManifest("2.6.x"); } catch (AssertionError e) { - if (e.getMessage() != null && e.getMessage().contains("2.5.")) { - // we're likely running a boot 2.5 compatibility test, try 2.5 - verifyCurrentVersionFromManifest("2.5"); - verifyCurrentVersionFromManifest("2.5.x"); + if (e.getMessage() != null && e.getMessage().contains("2.7.")) { + // we're likely running a boot 2.7 compatibility test, try 2.7 + verifyCurrentVersionFromManifest("2.7"); + verifyCurrentVersionFromManifest("2.7.x"); } else { throw e; @@ -204,7 +204,7 @@ public class SpringBootDependencyTests { @Test public void should_match_against_current_predicate() { - List acceptedVersions = Collections.singletonList("2.4"); + List acceptedVersions = Collections.singletonList("2.6"); SpringBootVersionVerifier versionVerifier = new SpringBootVersionVerifier(acceptedVersions) { @Override String getVersionFromManifest() { @@ -212,7 +212,7 @@ public class SpringBootDependencyTests { } }; versionVerifier.ACCEPTED_VERSIONS.clear(); - versionVerifier.ACCEPTED_VERSIONS.put("2.4", versionVerifier.is2_4()); + versionVerifier.ACCEPTED_VERSIONS.put("2.6", versionVerifier.is2_6()); VerificationResult verificationResult = versionVerifier.verify(); @@ -222,7 +222,7 @@ public class SpringBootDependencyTests { @Test public void should_match_against_current_predicate_with_version_ending_with_x() { - List acceptedVersions = Collections.singletonList("2.4.x"); + List acceptedVersions = Collections.singletonList("2.6.x"); SpringBootVersionVerifier versionVerifier = new SpringBootVersionVerifier(acceptedVersions) { @Override String getVersionFromManifest() { @@ -230,7 +230,7 @@ public class SpringBootDependencyTests { } }; versionVerifier.ACCEPTED_VERSIONS.clear(); - versionVerifier.ACCEPTED_VERSIONS.put("2.4", versionVerifier.is2_4()); + versionVerifier.ACCEPTED_VERSIONS.put("2.6", versionVerifier.is2_6()); VerificationResult verificationResult = versionVerifier.verify();