Skip to content

Set 500 status for disconnected client exceptions#36868

Open
king-407 wants to merge 1 commit into
spring-projects:mainfrom
king-407:issue-34481-disconnected-client-status
Open

Set 500 status for disconnected client exceptions#36868
king-407 wants to merge 1 commit into
spring-projects:mainfrom
king-407:issue-34481-disconnected-client-status

Conversation

@king-407
Copy link
Copy Markdown

@king-407 king-407 commented Jun 3, 2026

Summary

This PR updates Spring MVC disconnected-client exception handling to set the response status to 500 instead of leaving it at the default 200 status.

The change covers both paths discussed in gh-34481:

  • DefaultHandlerExceptionResolver, which handles default Spring MVC exception resolution
  • ExceptionHandlerExceptionResolver, where an @ExceptionHandler rethrows a disconnected-client style exception

For an actual disconnected client, the client will not observe the response. For cases where the exception is incorrectly classified as a disconnected-client exception, this avoids silently reporting a failed request as successful.

This is based on the latest issue discussion; happy to adjust the scope or implementation if the maintainers prefer a different approach.

Testing

  • ./gradlew :spring-webmvc:test --tests org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolverTests --tests org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolverTests
  • git diff --check

See gh-34481

Signed-off-by: king-407 <95581750+king-407@users.noreply.github.com>
@king-407 king-407 marked this pull request as draft June 3, 2026 15:10
@king-407
Copy link
Copy Markdown
Author

king-407 commented Jun 3, 2026

This PR is based on the latest discussion around setting a 500 response status for disconnected-client exceptions instead of leaving the response at the default 200.

The change covers both Spring MVC paths discussed in the issue: DefaultHandlerExceptionResolver and ExceptionHandlerExceptionResolver. I also added focused tests for IOException("Broken pipe"), including the case where an @ExceptionHandler rethrows the exception.

Happy to adjust the scope or implementation if the maintainers prefer a different approach.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Jun 3, 2026
@king-407 king-407 marked this pull request as ready for review June 3, 2026 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: waiting-for-triage An issue we've not yet triaged or decided on

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants