8349543: LinkedBlockingDeque does not immediately throw InterrruptedException in put/take#23464
8349543: LinkedBlockingDeque does not immediately throw InterrruptedException in put/take#23464kabutz wants to merge 2 commits into
Conversation
…lready interrupted when putXXX() and takeXXX() are called
…ast() all throw InterruptedException immediately if the thread is interrupted.
|
👋 Welcome back kabutz! A progress list of the required criteria for merging this PR into |
|
❗ This change is not yet ready to be integrated. |
|
Thanks for finding this. The only question is whether we believe that any existing usage might depend on current behavior, and if so should it be done anyway? |
Good question - your call Doug. LinkedBlockingDeque's comment is the same as LInkedBlockingQueue's (inherited from BlockingQueue): "@throws InterruptedException if interrupted while waiting" - however all the other classes that do throw this InterruptedException would do so on entry, even if we are not technically waiting. Other examples where this behaviour is consistent is LinkedTransferQueue.take(), PriorityBlockingQueue.take(), etc.: |
Martin-Buchholz
left a comment
There was a problem hiding this comment.
I will give this review a bit of my 1% openjdk time
|
I think this is okay. Anything calling these methods already has to deal with InterruptedException. I see that the implementation offerFirst/offerLast/pollFirst/pollLast is using lockInterruptibly so if usage extends to these methods then there is already the possibility of the exception when calling them with the interrupt status set. Given the behavior change then a CSR + release notes would be good but I think it's overall. |
|
@kabutz This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration! |
|
Should we drop this PR or continue with it? I noticed that the timed offer() and poll() methods are consistent with the way that LinkedBlockingQueue works, in other words, they throw the InterruptedException as soon as we enter the methods. They use lock.lockInterruptibly(), which I was suggesting we use for put() and take(). |
|
@kabutz This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration! |
|
@kabutz This pull request has been inactive for more than 8 weeks and will now be automatically closed. If you would like to continue working on this pull request in the future, feel free to reopen it! This can be done using the |
|
These changes have been included in #24925 |
The LinkedBlockingDeque does not behave consistently with other concurrency components. If we call putFirst(), putLast(), takeFirst(), or takeLast() with a thread that is interrupted, it does not immediately throw an InterruptedException, the way that ArrayBlockingQueue and LInkedBlockingQueue does, because instead of lockInterruptibly(), we call lock(). It will only throw an InterruptedException if the queue is full (on put) or empty (on take). Since interruptions are frequently used as a shutdown mechanism, this might prevent code from ever shutting down.
Progress
Integration blocker
Issue
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/23464/head:pull/23464$ git checkout pull/23464Update a local copy of the PR:
$ git checkout pull/23464$ git pull https://git.openjdk.org/jdk.git pull/23464/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 23464View PR using the GUI difftool:
$ git pr show -t 23464Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/23464.diff
Using Webrev
Link to Webrev Comment