Set 500 status for disconnected client exceptions#36868
Open
king-407 wants to merge 1 commit into
Open
Conversation
Signed-off-by: king-407 <95581750+king-407@users.noreply.github.com>
Author
|
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: Happy to adjust the scope or implementation if the maintainers prefer a different approach. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 resolutionExceptionHandlerExceptionResolver, where an@ExceptionHandlerrethrows a disconnected-client style exceptionFor 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.ExceptionHandlerExceptionResolverTestsgit diff --checkSee gh-34481