From 44eab8def20d656b1306faa7365dd35402f41cfd Mon Sep 17 00:00:00 2001 From: spencergibb Date: Mon, 1 Feb 2021 12:41:16 -0500 Subject: [PATCH] Adds boot 2.4 support in SpringBootVersionVerifier. The reason errors weren't reported before with boot 2.4 and cloud 2020.0 is because of an error in logic. See gh-895 See also gh-896 --- .../SpringBootVersionVerifier.java | 24 +++++++++++++++++++ .../SpringBootDependencyTests.java | 14 ++++------- 2 files changed, 28 insertions(+), 10 deletions(-) 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 53d2bef6..a4daadb7 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 @@ -41,6 +41,7 @@ class SpringBootVersionVerifier implements CompatibilityVerifier { this.put("2.1", is2_1()); this.put("2.2", is2_2()); this.put("2.3", is2_3()); + this.put("2.4", is2_4()); } }; @@ -189,6 +190,29 @@ class SpringBootVersionVerifier implements CompatibilityVerifier { }; } + CompatibilityPredicate is2_4() { + return new CompatibilityPredicate() { + + @Override + public String toString() { + return "Predicate for Boot 2.4"; + } + + @Override + public boolean isCompatible() { + try { + // since 2.4 + Class.forName("org.springframework.boot.Bootstrapper"); + return true; + } + catch (ClassNotFoundException e) { + return false; + } + + } + }; + } + private String errorDescription() { String versionFromManifest = getVersionFromManifest(); if (StringUtils.hasText(versionFromManifest)) { 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 eb4f8236..ab6a5e22 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 @@ -21,7 +21,6 @@ import java.util.Collections; import java.util.List; import java.util.concurrent.atomic.AtomicBoolean; -import org.junit.Ignore; import org.junit.Test; import static org.assertj.core.api.BDDAssertions.then; @@ -109,12 +108,7 @@ public class SpringBootDependencyTests { } }; versionVerifier.ACCEPTED_VERSIONS.clear(); - versionVerifier.ACCEPTED_VERSIONS.put("2.5", new CompatibilityPredicate() { - @Override - public boolean isCompatible() { - return true; - } - }); + versionVerifier.ACCEPTED_VERSIONS.put("2.5", () -> true); VerificationResult verificationResult = versionVerifier.verify(); @@ -183,11 +177,11 @@ public class SpringBootDependencyTests { then(verificationResult.action).isEmpty(); } - @Ignore // FIXME: https://github.com/spring-cloud/spring-cloud-commons/issues/717 + //@Ignore // FIXME: https://github.com/spring-cloud/spring-cloud-commons/issues/717 @Test public void should_match_against_current_manifest() { - verifyCurrentVersionFromManifest("2.3"); - verifyCurrentVersionFromManifest("2.3.x"); + verifyCurrentVersionFromManifest("2.4"); + verifyCurrentVersionFromManifest("2.4.x"); } private void verifyCurrentVersionFromManifest(String version) {