@ControllerAdvice
public class GlobalExceptionHandler {
@ExceptionHandler(OptimisticLockingFailureException.class)
@ResponseStatus(code = CONFLICT, reason = "optimistic.locking.failure")
public void handleConflict() {
}
}
If I move @ResponseStatus
to Exception, It works fine.
https://github.com/spring-projects/spring-framework/blob/b595dc1dfad9db534ca7b9e8f46bb9926b88ab5a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ServletInvocableHandlerMethod.java#L147-L149 should keep consistency with https://github.com/spring-projects/spring-framework/blob/b595dc1dfad9db534ca7b9e8f46bb9926b88ab5a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/annotation/ResponseStatusExceptionResolver.java#L157-L159