diff --git a/gax-java/gax-httpjson/src/main/java/com/google/api/gax/httpjson/HttpJsonClientCallImpl.java b/gax-java/gax-httpjson/src/main/java/com/google/api/gax/httpjson/HttpJsonClientCallImpl.java index 6b9073544f..1aafbe73c1 100644 --- a/gax-java/gax-httpjson/src/main/java/com/google/api/gax/httpjson/HttpJsonClientCallImpl.java +++ b/gax-java/gax-httpjson/src/main/java/com/google/api/gax/httpjson/HttpJsonClientCallImpl.java @@ -173,20 +173,20 @@ public void start(Listener responseListener, HttpJsonMetadata request Preconditions.checkState(this.listener == null, "The call is already started"); this.listener = responseListener; this.requestHeaders = requestHeaders; - } - // Use the timeout duration value instead of calculating the future Instant - // Only schedule the deadline if the RPC timeout has been set in the RetrySettings - Duration timeout = callOptions.getTimeout(); - if (timeout != null) { - // The future timeout value is guaranteed to not be a negative value as the - // RetryAlgorithm will not retry - long timeoutMs = timeout.toMillis(); - // Assign the scheduled future so that it can be cancelled if the timeout task - // is not needed (response received prior to timeout) - timeoutFuture = - this.deadlineCancellationExecutor.schedule( - this::timeout, timeoutMs, TimeUnit.MILLISECONDS); + // Use the timeout duration value instead of calculating the future Instant + // Only schedule the deadline if the RPC timeout has been set in the RetrySettings + Duration timeout = callOptions.getTimeout(); + if (timeout != null) { + // The future timeout value is guaranteed to not be a negative value as the + // RetryAlgorithm will not retry + long timeoutMs = timeout.toMillis(); + // Assign the scheduled future so that it can be cancelled if the timeout task + // is not needed (response received prior to timeout) + timeoutFuture = + this.deadlineCancellationExecutor.schedule( + this::timeout, timeoutMs, TimeUnit.MILLISECONDS); + } } }