8309545: Thread.interrupted from virtual thread needlessly resets interrupt status

Reviewed-by: rpressler, dholmes, jpai
This commit is contained in:
Alan Bateman 2023-06-09 07:30:03 +00:00
parent f91e9ba757
commit 97df6cf55a

View file

@ -874,13 +874,14 @@ final class VirtualThread extends BaseVirtualThread {
@Override @Override
boolean getAndClearInterrupt() { boolean getAndClearInterrupt() {
assert Thread.currentThread() == this; assert Thread.currentThread() == this;
synchronized (interruptLock) { boolean oldValue = interrupted;
boolean oldValue = interrupted; if (oldValue) {
if (oldValue) synchronized (interruptLock) {
interrupted = false; interrupted = false;
carrierThread.clearInterrupt(); carrierThread.clearInterrupt();
return oldValue; }
} }
return oldValue;
} }
@Override @Override