Skip to content

Commit ab20a12

Browse files
authored
Cancel owned Futures *before* declaring termination. (#12426)
Fixes BinderClientTransportTest#testAsyncSecurityPolicyCancelledUponExternalTermination and others which have been flaky since #12283. @HyunSangHan
1 parent 9662f0f commit ab20a12

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

binder/src/main/java/io/grpc/binder/internal/BinderTransport.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -320,15 +320,16 @@ final void shutdownInternal(Status shutdownStatus, boolean forceTerminate) {
320320
inbound.closeAbnormal(shutdownStatus);
321321
}
322322
}
323-
synchronized (this) {
324-
notifyTerminated();
325-
}
326-
releaseExecutors();
327-
323+
328324
for (Future<?> future : futuresToCancel) {
329325
// Not holding any locks here just in case some listener runs on a direct Executor.
330326
future.cancel(false); // No effect if already isDone().
331327
}
328+
329+
synchronized (this) {
330+
notifyTerminated();
331+
}
332+
releaseExecutors();
332333
});
333334
}
334335
}

0 commit comments

Comments
 (0)