< prev index next >
src/java.base/share/classes/java/util/concurrent/CompletableFuture.java
Print this page
8234131: Miscellaneous changes imported from jsr166 CVS 2020-06
Reviewed-by: martin
@@ -1869,10 +1869,12 @@
/**
* Returns raw result after waiting, or null if interruptible and
* interrupted.
*/
private Object waitingGet(boolean interruptible) {
+ if (interruptible && Thread.interrupted())
+ return null;
Signaller q = null;
boolean queued = false;
Object r;
while ((r = result) == null) {
if (q == null) {
@@ -1880,28 +1882,28 @@
if (Thread.currentThread() instanceof ForkJoinWorkerThread)
ForkJoinPool.helpAsyncBlocker(defaultExecutor(), q);
}
else if (!queued)
queued = tryPushStack(q);
+ else if (interruptible && q.interrupted) {
+ q.thread = null;
+ cleanStack();
+ return null;
+ }
else {
try {
ForkJoinPool.managedBlock(q);
} catch (InterruptedException ie) { // currently cannot happen
q.interrupted = true;
}
- if (q.interrupted && interruptible)
- break;
}
}
- if (q != null && queued) {
+ if (q != null) {
q.thread = null;
- if (!interruptible && q.interrupted)
+ if (q.interrupted)
Thread.currentThread().interrupt();
- if (r == null)
- cleanStack();
}
- if (r != null || (r = result) != null)
postComplete();
return r;
}
/**
< prev index next >