8336384: AbstractQueuedSynchronizer.acquire should cancel acquire when failing due to a LinkageError or other errors
Reviewed-by: alanb
This commit is contained in:
parent
ba69ed7c58
commit
fbe4cc96e2
@ -369,14 +369,19 @@ public abstract class AbstractQueuedLongSynchronizer
|
|||||||
} else if (node.status == 0) {
|
} else if (node.status == 0) {
|
||||||
node.status = WAITING; // enable signal and recheck
|
node.status = WAITING; // enable signal and recheck
|
||||||
} else {
|
} else {
|
||||||
long nanos;
|
|
||||||
spins = postSpins = (byte)((postSpins << 1) | 1);
|
spins = postSpins = (byte)((postSpins << 1) | 1);
|
||||||
|
try {
|
||||||
|
long nanos;
|
||||||
if (!timed)
|
if (!timed)
|
||||||
LockSupport.park(this);
|
LockSupport.park(this);
|
||||||
else if ((nanos = time - System.nanoTime()) > 0L)
|
else if ((nanos = time - System.nanoTime()) > 0L)
|
||||||
LockSupport.parkNanos(this, nanos);
|
LockSupport.parkNanos(this, nanos);
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
|
} catch (Error | RuntimeException ex) {
|
||||||
|
cancelAcquire(node, interrupted, interruptible); // cancel & rethrow
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
node.clearStatus();
|
node.clearStatus();
|
||||||
if ((interrupted |= Thread.interrupted()) && interruptible)
|
if ((interrupted |= Thread.interrupted()) && interruptible)
|
||||||
break;
|
break;
|
||||||
|
@ -748,14 +748,19 @@ public abstract class AbstractQueuedSynchronizer
|
|||||||
} else if (node.status == 0) {
|
} else if (node.status == 0) {
|
||||||
node.status = WAITING; // enable signal and recheck
|
node.status = WAITING; // enable signal and recheck
|
||||||
} else {
|
} else {
|
||||||
long nanos;
|
|
||||||
spins = postSpins = (byte)((postSpins << 1) | 1);
|
spins = postSpins = (byte)((postSpins << 1) | 1);
|
||||||
|
try {
|
||||||
|
long nanos;
|
||||||
if (!timed)
|
if (!timed)
|
||||||
LockSupport.park(this);
|
LockSupport.park(this);
|
||||||
else if ((nanos = time - System.nanoTime()) > 0L)
|
else if ((nanos = time - System.nanoTime()) > 0L)
|
||||||
LockSupport.parkNanos(this, nanos);
|
LockSupport.parkNanos(this, nanos);
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
|
} catch (Error | RuntimeException ex) {
|
||||||
|
cancelAcquire(node, interrupted, interruptible); // cancel & rethrow
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
node.clearStatus();
|
node.clearStatus();
|
||||||
if ((interrupted |= Thread.interrupted()) && interruptible)
|
if ((interrupted |= Thread.interrupted()) && interruptible)
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user