Skip to content

Commit

Permalink
Adds boot 3.1 support in SpringBootVersionVerifier
Browse files Browse the repository at this point in the history
  • Loading branch information
spencergibb committed Feb 8, 2023
1 parent 3bbd952 commit a2cc426
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.apache.commons.logging.LogFactory;

import org.springframework.boot.SpringBootVersion;
import org.springframework.boot.autoconfigure.validation.ValidationConfigurationCustomizer;
import org.springframework.util.StringUtils;

/**
Expand All @@ -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());
}
};

Expand Down Expand Up @@ -95,6 +97,30 @@ public boolean isCompatible() {
};
}

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)) {
Expand Down

0 comments on commit a2cc426

Please sign in to comment.