Correctly apply required API version validation

Closes gh-35386
This commit is contained in:
rstoyanchev
2025-08-28 15:50:33 +03:00
parent 442a2d0ca2
commit a7e3a438c9
4 changed files with 32 additions and 24 deletions
@@ -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;
}
/**