From 7a7fb7fc3f04f4bda66ec1dee92d12aa34280d34 Mon Sep 17 00:00:00 2001 From: Avgustin Marinov Date: Fri, 2 Feb 2024 18:32:46 +0200 Subject: [PATCH] Fix Spring 3.2.2 migration (#1586) HandlerMethodValidationException is thrown in some validations instead MethodArgumentNotValidException handle it also Signed-off-by: Marinov Avgustin --- .../hawkbit/rest/exception/ResponseExceptionHandler.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/hawkbit-rest/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/exception/ResponseExceptionHandler.java b/hawkbit-rest/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/exception/ResponseExceptionHandler.java index 5a46295e5..ea935b9bd 100644 --- a/hawkbit-rest/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/exception/ResponseExceptionHandler.java +++ b/hawkbit-rest/hawkbit-rest-core/src/main/java/org/eclipse/hawkbit/rest/exception/ResponseExceptionHandler.java @@ -31,6 +31,7 @@ import org.springframework.http.converter.HttpMessageNotReadableException; import org.springframework.web.bind.MethodArgumentNotValidException; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.method.annotation.HandlerMethodValidationException; import org.springframework.web.multipart.MultipartException; import com.google.common.collect.Iterables; @@ -164,7 +165,10 @@ public class ResponseExceptionHandler { * @return the entity to be responded containing the exception information * as entity. */ - @ExceptionHandler({ HttpMessageNotReadableException.class, MethodArgumentNotValidException.class, IllegalArgumentException.class }) + @ExceptionHandler({ + HttpMessageNotReadableException.class, + MethodArgumentNotValidException.class, HandlerMethodValidationException.class, + IllegalArgumentException.class }) public ResponseEntity handleExceptionCausedByIncorrectRequestBody(final HttpServletRequest request, final Exception ex) { logRequest(request, ex);