Skip to content

Commit

Permalink
Add a timeout to AltsHandshakerStub
Browse files Browse the repository at this point in the history
  • Loading branch information
susinmotion authored and ejona86 committed Nov 9, 2020
1 parent beb3232 commit d154aa3
Showing 1 changed file with 8 additions and 1 deletion.
Expand Up @@ -16,6 +16,8 @@

package io.grpc.alts.internal;

import static java.util.concurrent.TimeUnit.SECONDS;

import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Optional;
import io.grpc.alts.internal.HandshakerServiceGrpc.HandshakerServiceStub;
Expand All @@ -32,8 +34,13 @@ class AltsHandshakerStub {
new ArrayBlockingQueue<>(1);
private final AtomicReference<String> exceptionMessage = new AtomicReference<>();

private static final long HANDSHAKE_RPC_DEADLINE_SECS = 20;

AltsHandshakerStub(HandshakerServiceStub serviceStub) {
this.writer = serviceStub.doHandshake(this.reader);
this.writer =
serviceStub
.withDeadlineAfter(HANDSHAKE_RPC_DEADLINE_SECS, SECONDS)
.doHandshake(this.reader);
}

@VisibleForTesting
Expand Down

0 comments on commit d154aa3

Please sign in to comment.