mirror of https://github.com/grpc/grpc-java.git
Move pendingDeadline.cancel out of synchronized block
This commit is contained in:
parent
e73f31a561
commit
3c4d3d2bb2
|
|
@ -826,18 +826,22 @@ public class Context {
|
||||||
@CanIgnoreReturnValue
|
@CanIgnoreReturnValue
|
||||||
public boolean cancel(Throwable cause) {
|
public boolean cancel(Throwable cause) {
|
||||||
boolean triggeredCancel = false;
|
boolean triggeredCancel = false;
|
||||||
|
ScheduledFuture<?> localPendingDeadline = null;
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
if (!cancelled) {
|
if (!cancelled) {
|
||||||
cancelled = true;
|
cancelled = true;
|
||||||
if (pendingDeadline != null) {
|
if (pendingDeadline != null) {
|
||||||
// If we have a scheduled cancellation pending attempt to cancel it.
|
// If we have a scheduled cancellation pending attempt to cancel it.
|
||||||
pendingDeadline.cancel(false);
|
localPendingDeadline = pendingDeadline;
|
||||||
pendingDeadline = null;
|
pendingDeadline = null;
|
||||||
}
|
}
|
||||||
this.cancellationCause = cause;
|
this.cancellationCause = cause;
|
||||||
triggeredCancel = true;
|
triggeredCancel = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (localPendingDeadline != null) {
|
||||||
|
localPendingDeadline.cancel(false);
|
||||||
|
}
|
||||||
if (triggeredCancel) {
|
if (triggeredCancel) {
|
||||||
notifyAndClearListeners();
|
notifyAndClearListeners();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue