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
This commit is contained in:
spencergibb
2021-02-01 12:41:16 -05:00
parent 5db02e2bee
commit 44eab8def2
2 changed files with 28 additions and 10 deletions

View File

@@ -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)) {

View File

@@ -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) {