Browse Source

Updated SpringBootVersionVerifier to require boot 2.6

pull/979/head
spencergibb 3 years ago
parent
commit
f8f549cc72
No known key found for this signature in database
GPG Key ID: 7788A47380690861
  1. 10
      pom.xml
  2. 2
      spring-cloud-commons/src/main/java/org/springframework/cloud/configuration/CompatibilityVerifierProperties.java
  3. 34
      spring-cloud-commons/src/main/java/org/springframework/cloud/configuration/SpringBootVersionVerifier.java
  4. 20
      spring-cloud-commons/src/test/java/org/springframework/cloud/configuration/SpringBootDependencyTests.java

10
pom.xml

@ -155,6 +155,16 @@ @@ -155,6 +155,16 @@
<groupId>org.springframework.security.oauth.boot</groupId>
<artifactId>spring-security-oauth2-autoconfigure</artifactId>
<version>${spring-security-oauth2-autoconfigure.version}</version>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</dependencyManagement>

2
spring-cloud-commons/src/main/java/org/springframework/cloud/configuration/CompatibilityVerifierProperties.java

@ -37,7 +37,7 @@ public class CompatibilityVerifierProperties { @@ -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<String> compatibleBootVersions = Arrays.asList("2.4.x", "2.5.x");
private List<String> compatibleBootVersions = Arrays.asList("2.6.x");
public boolean isEnabled() {
return this.enabled;

34
spring-cloud-commons/src/main/java/org/springframework/cloud/configuration/SpringBootVersionVerifier.java

@ -35,8 +35,7 @@ class SpringBootVersionVerifier implements CompatibilityVerifier { @@ -35,8 +35,7 @@ class SpringBootVersionVerifier implements CompatibilityVerifier {
final Map<String, CompatibilityPredicate> ACCEPTED_VERSIONS = new HashMap<String, CompatibilityPredicate>() {
{
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 { @@ -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) {

20
spring-cloud-commons/src/test/java/org/springframework/cloud/configuration/SpringBootDependencyTests.java

@ -176,14 +176,14 @@ public class SpringBootDependencyTests { @@ -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 { @@ -204,7 +204,7 @@ public class SpringBootDependencyTests {
@Test
public void should_match_against_current_predicate() {
List<String> acceptedVersions = Collections.singletonList("2.4");
List<String> acceptedVersions = Collections.singletonList("2.6");
SpringBootVersionVerifier versionVerifier = new SpringBootVersionVerifier(acceptedVersions) {
@Override
String getVersionFromManifest() {
@ -212,7 +212,7 @@ public class SpringBootDependencyTests { @@ -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 { @@ -222,7 +222,7 @@ public class SpringBootDependencyTests {
@Test
public void should_match_against_current_predicate_with_version_ending_with_x() {
List<String> acceptedVersions = Collections.singletonList("2.4.x");
List<String> acceptedVersions = Collections.singletonList("2.6.x");
SpringBootVersionVerifier versionVerifier = new SpringBootVersionVerifier(acceptedVersions) {
@Override
String getVersionFromManifest() {
@ -230,7 +230,7 @@ public class SpringBootDependencyTests { @@ -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();

Loading…
Cancel
Save