Skip to content

It seems that CallOptions.withDeadlineAfter does not provide a fully functional timeout #1540

Closed
@LeeYeeze

Description

@LeeYeeze

CallOptions.withDeadlineAfter works when client and server are connected or can be connected but the server can not respond in time. When it comes to network partition, a CallOptions.blockingUnaryCall will wait about 30s to throw an exception despite the deadline.

I can walk around this by giving timeout parameters to the future.get() inside CallOptions.getUnchecked(Future future) like this

private static <V> V getUnchecked(Future<V> future) {
        try {
          return future.get(2, TimeUnit.SECONDS);
        } catch (InterruptedException e) {
          Thread.currentThread().interrupt();
          throw Status.CANCELLED.withCause(e).asRuntimeException();
        } catch (ExecutionException e) {
          throw Status.fromThrowable(e).asRuntimeException();
        } catch (TimeoutException e) {
          throw Status.fromThrowable(e).asRuntimeException();
        }

But I believe there should be a better way @ejona86

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions