Restore thread interrupt flag in DefaultMvcResult when catching InterruptedException#36876
Open
leestana01 wants to merge 1 commit into
Open
Restore thread interrupt flag in DefaultMvcResult when catching InterruptedException#36876leestana01 wants to merge 1 commit into
DefaultMvcResult when catching InterruptedException#36876leestana01 wants to merge 1 commit into
Conversation
… InterruptedException awaitAsyncDispatch() catches InterruptedException, returns false, and discards the interruption. Catching InterruptedException without rethrowing should restore the interrupt status (as is done across the framework's main sources), so re-assert it before returning false. Signed-off-by: leestana01 <leestana01@naver.com>
Contributor
Author
|
One note on the test: |
DefaultMvcResult when catching InterruptedException
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.
DefaultMvcResult.awaitAsyncDispatch()catchesInterruptedExceptionand returnsfalsewithout restoring the thread's interrupt status, so the interruption is silently lost.When
InterruptedExceptionis caught without being rethrown, the interrupt status should be reasserted, as the framework already does elsewhere. For example,ConcurrencyThrottleSupportre-interrupts the current thread on the same exception ("Re-interrupt current thread, to allow other threads to react."). This applies the same handling withThread.currentThread().interrupt()before returningfalse.There is no other behavior change: an interruption already makes
getAsyncResult(...)throwIllegalStateExceptionvia thefalsereturn, so this only preserves the interrupt status as it propagates. The added test interrupts the current thread before callinggetAsyncResult(...)and verifies the interrupt status is still set afterwards.