Closed
Description
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