@Test public void soTimeoutExceeded() throws InterruptedException, ExecutionException { final Client client = new ApacheClient.Builder().withSoTimeout(1).build(); final Request request = new HttpRequest.Builder(Method.GET, this.delayUri, this.operation).build(); final Response response = client.execute(request).get(); assertThat(response.getStatusCode(), is(599)); }
@Override public ListenableFuture<Response> execute(final Request request) { checkNotNull(request); final BlockingHttpOperation operation = new BlockingHttpOperation(request); final ListenableFuture<Response> baseFuture = this.executorService.submit(operation); return new ForwardingListenableFuture.SimpleForwardingListenableFuture<Response>(baseFuture) { @Override public boolean cancel(final boolean mayInterruptIfRunning) { operation.getApacheRequest().abort(); return delegate().cancel(mayInterruptIfRunning); } }; }
ApacheClient implements Client { @Override public ListenableFuture<Response> execute(final Request request) { checkNotNull(request); final BlockingHttpOperation operation = new BlockingHttpOperation(request); final ListenableFuture<Response> baseFuture = this.executorService.submit(operation); return new ForwardingListenableFuture.SimpleForwardingListenableFuture<Response>(baseFuture) { @Override public boolean cancel(final boolean mayInterruptIfRunning) { operation.getApacheRequest().abort(); return delegate().cancel(mayInterruptIfRunning); } }; } }
ApacheClient implements Client { @Override public ListenableFuture<Response> execute(final Request request) { checkNotNull(request); final BlockingHttpOperation operation = new BlockingHttpOperation(request); final ListenableFuture<Response> baseFuture = this.executorService.submit(operation); return new ForwardingListenableFuture.SimpleForwardingListenableFuture<Response>(baseFuture) { @Override public boolean cancel(final boolean mayInterruptIfRunning) { operation.getApacheRequest().abort(); return delegate().cancel(mayInterruptIfRunning); } }; } private  ApacheClient(final Builder builder); }
ApacheClient implements Client { @Override public ListenableFuture<Response> execute(final Request request) { checkNotNull(request); final BlockingHttpOperation operation = new BlockingHttpOperation(request); final ListenableFuture<Response> baseFuture = this.executorService.submit(operation); return new ForwardingListenableFuture.SimpleForwardingListenableFuture<Response>(baseFuture) { @Override public boolean cancel(final boolean mayInterruptIfRunning) { operation.getApacheRequest().abort(); return delegate().cancel(mayInterruptIfRunning); } }; } private  ApacheClient(final Builder builder); @Override ListenableFuture<Response> execute(final Request request); @Override ListenableFuture<Integer> shutdown(final boolean immediate, final int timeout); @Override String toString(); }
ApacheClient implements Client { @Override public ListenableFuture<Response> execute(final Request request) { checkNotNull(request); final BlockingHttpOperation operation = new BlockingHttpOperation(request); final ListenableFuture<Response> baseFuture = this.executorService.submit(operation); return new ForwardingListenableFuture.SimpleForwardingListenableFuture<Response>(baseFuture) { @Override public boolean cancel(final boolean mayInterruptIfRunning) { operation.getApacheRequest().abort(); return delegate().cancel(mayInterruptIfRunning); } }; } private  ApacheClient(final Builder builder); @Override ListenableFuture<Response> execute(final Request request); @Override ListenableFuture<Integer> shutdown(final boolean immediate, final int timeout); @Override String toString();  }