Skip to content

Commit fc77da4

Browse files
committed
binder: Rename method, relocate calls, and remove null assignments
Rename cancelAsync to cancelAsyncIfNeeded, move future cancellation next to readyTimeoutFuture, and remove unnecessary null assignments. Signed-off-by: Hyunsang Han <gustkd3@gmail.com>
1 parent 4d7ed66 commit fc77da4

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

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

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -316,14 +316,11 @@ void notifyTerminated() {
316316
readyTimeoutFuture.cancel(false);
317317
readyTimeoutFuture = null;
318318
}
319+
cancelAsyncIfNeeded(preAuthResultFuture);
320+
cancelAsyncIfNeeded(authResultFuture);
319321

320322
serviceBinding.unbind();
321323
clientTransportListener.transportTerminated();
322-
323-
cancelAsync(preAuthResultFuture);
324-
cancelAsync(authResultFuture);
325-
preAuthResultFuture = null;
326-
authResultFuture = null;
327324
}
328325

329326
@Override
@@ -404,7 +401,7 @@ protected void handlePingResponse(Parcel parcel) {
404401
* Useful when the caller wants to cancel while holding locks but the future is visible to
405402
* user code which might have added listeners to run on directExecutor().
406403
*/
407-
private void cancelAsync(@Nullable ListenableFuture<?> future) {
404+
private void cancelAsyncIfNeeded(@Nullable ListenableFuture<?> future) {
408405
if (future != null && !future.isDone()) {
409406
offloadExecutor.execute(() -> future.cancel(false));
410407
}

0 commit comments

Comments
 (0)