mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-09-23 06:29:10 +00:00
Correctly apply required API version validation
Closes gh-35386
This commit is contained in:
@@ -70,17 +70,20 @@ public interface ApiVersionStrategy {
|
||||
*/
|
||||
default @Nullable Comparable<?> resolveParseAndValidateVersion(HttpServletRequest request) {
|
||||
String value = resolveVersion(request);
|
||||
Comparable<?> version;
|
||||
if (value == null) {
|
||||
return getDefaultVersion();
|
||||
version = getDefaultVersion();
|
||||
}
|
||||
try {
|
||||
Comparable<?> version = parseVersion(value);
|
||||
validateVersion(version, request);
|
||||
return version;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
throw new InvalidApiVersionException(value, null, ex);
|
||||
else {
|
||||
try {
|
||||
version = parseVersion(value);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
throw new InvalidApiVersionException(value, null, ex);
|
||||
}
|
||||
}
|
||||
validateVersion(version, request);
|
||||
return version;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user