forked from spring-projects/spring-boot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Retry read on ClosedByInterruptException
In spring-projectsgh-38154, we started handling ClosedByInterruptException. The FileChannel was repaired by recreating it and then the exception was rethrown. This allowed other threads to use the channel that had been read by an interrupted thread while allowing that interruption to continue. This approach has proven to be insufficient as there are scenarios where the read needs to succeed on the interrupted thread. This commit updates the handling of ClosedByInterruptException so that this is the case. The FileChannel is recreated as before but the thread's interrupted flag is now cleared before retrying the read. The flag is then reinstated so that any subsequent actions that should fail due to the interruption will do so. We could clear and reinstate the interrupted flag before the first read, rather than catching ClosedByInterruptException. This approach was rejected as it will have an impact on the performance of the happy path where the thread hasn't been interrupted. Fixes spring-projectsgh-38611
- Loading branch information
1 parent
9eae176
commit e697024
Showing
2 changed files
with
27 additions
and
25 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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