Adds boot 3.1 support in SpringBootVersionVerifier

This commit is contained in:
spencergibb
2023-02-08 13:29:48 -05:00
parent 3bbd9524ad
commit a2cc42614c
2 changed files with 27 additions and 1 deletions

View File

@@ -36,7 +36,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 = List.of("3.0.x");
private List<String> compatibleBootVersions = List.of("3.0.x", "3.1.x");
public boolean isEnabled() {
return this.enabled;

View File

@@ -24,6 +24,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.boot.SpringBootVersion;
import org.springframework.boot.autoconfigure.validation.ValidationConfigurationCustomizer;
import org.springframework.util.StringUtils;
/**
@@ -36,6 +37,7 @@ class SpringBootVersionVerifier implements CompatibilityVerifier {
final Map<String, CompatibilityPredicate> ACCEPTED_VERSIONS = new HashMap<>() {
{
this.put("3.0", is3_0());
this.put("3.1", is3_1());
}
};
@@ -95,6 +97,30 @@ class SpringBootVersionVerifier implements CompatibilityVerifier {
};
}
CompatibilityPredicate is3_1() {
return new CompatibilityPredicate() {
@Override
public String toString() {
return "Predicate for Boot 3.1";
}
@Override
public boolean isCompatible() {
try {
// since 3.1
ValidationConfigurationCustomizer.class.getMethod("setIgnoreRegistrationFailure", boolean.class);
return true;
}
catch (NoSuchMethodException e) {
return false;
}
}
};
}
private String errorDescription() {
String versionFromManifest = getVersionFromManifest();
if (StringUtils.hasText(versionFromManifest)) {