Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dimasadryantos opened this issue Dec 12, 2023 · 1 comment
Labels
for: external-project For an external project and not something we can fix status: duplicate A duplicate of another issue

Comments

@dimasadryantos
Copy link

dimasadryantos commented Dec 12, 2023

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.
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Dec 12, 2023
@wilkinsona
Copy link
Member

Duplicates #38733.

@wilkinsona wilkinsona closed this as not planned Won't fix, can't repro, duplicate, stale Dec 12, 2023
@wilkinsona wilkinsona added status: duplicate A duplicate of another issue for: external-project For an external project and not something we can fix and removed status: waiting-for-triage An issue we've not yet triaged labels Dec 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for: external-project For an external project and not something we can fix status: duplicate A duplicate of another issue
Projects
None yet
Development

No branches or pull requests

3 participants