Skip to content

spring.mvc.log-resolved-exception gets enabled by default. #29706

@cdprete

Description

@cdprete

Hi.
I'm using Spring Boot 2.6.3 and from the moment I've defined a ResponseEntityExceptionHandler I get an annoying warning log in the console of the type WARN 7072 --- [nio-8080-exec-2] .m.m.a.ExceptionHandlerExceptionResolver : Resolved [<fully-qualified-class-name>: <message>].

The handler is the following:

/**
 * @author Cosimo Damiano Prete
 * @since 09/02/2022
 */
@ControllerAdvice
class WebServiceExceptionHandler extends ResponseEntityExceptionHandler {

    @Valid
    @ExceptionHandler(ClientHttpException.class)
    public ResponseEntity<Object> handleClientHttpException(ClientHttpException ex, WebRequest request) {
        return handleExceptionInternal(ex, ErrorResponse.fromClientHttpException(ex), new HttpHeaders(), ex.statusCode(), request);
    }

    private record ErrorResponse(String code, String defaultMessage) {
        private static <E extends ClientHttpException> ErrorResponse fromClientHttpException(E ex) {
            return new ErrorResponse(ex.clientCode(), ex.getMessage());
        }
    }
}

By putting a breakpoint in the setter of WebMvcProperties I can see it actually gets called with the value true even though I don't have such value set at all in my application.yml file.
Strangely enough, if I explicitly set it to false then it stays like that (probably my props are applied later).

The issue doesn't seem to be caused by the ResponseEntityExceptionHandler, since I get the same also when the handler is defined as

/**
 * @author Cosimo Damiano Prete
 * @since 09/02/2022
 */
@ControllerAdvice
class WebServiceExceptionHandler {

    @ExceptionHandler(ClientHttpException.class)
    ResponseEntity<ErrorResponse> handleClientHttpException(ClientHttpException ex) {
        return new ResponseEntity<>(ErrorResponse.fromClientHttpException(ex), ex.statusCode());
    }

    private record ErrorResponse(String code, String defaultMessage) {
        private static <E extends ClientHttpException> ErrorResponse fromClientHttpException(E ex) {
            return new ErrorResponse(ex.clientCode(), ex.getMessage());
        }
    }
}

I've also tried adding an @Order annotation with highest priority (so that it would trigger my advice first), but it didn't help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: invalidAn issue that we don't feel is valid

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions