Skip to content

[SpringBoot 3.2.0] Every 404 Exception Error Will Be Route To 500 in @ControllerAdvice #38744

Closed as not planned
@dimasadryantos

Description

@dimasadryantos

Problem :

After updating to SpringBoot 3.2.0 everytime 404 NoResourceFoundException happened, it will re-route to 500 error due to default exception handler in @ControllerAdvice.

   @ExceptionHandler
    @ResponseStatus(INTERNAL_SERVER_ERROR)
    fun handleAllOtherExceptions(ex: Exception) {
        log.error(ex) { "exception occurred" }
    }

How to reproduce :

  • Clone example project on my Github
  • Go to deployment/local and run sh start.sh (it will start docker container locally)
  • Run SpringBoot application
  • Test using Postman with invalid url : localhost:8100/invalidURI/1
  • To simulate success case, remove exception handler code bellow in class RestExceptionHandler:
   @ExceptionHandler
    @ResponseStatus(INTERNAL_SERVER_ERROR)
    fun handleAllOtherExceptions(ex: Exception) {
        log.error(ex) { "exception occurred" }
    }

Expected behaviour

  • 404 NoResourceFoundException should not route to 500 error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    for: external-projectFor an external project and not something we can fixstatus: duplicateA duplicate of another issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions