use of com.linkedin.r2.transport.http.client.stream.http.HttpNettyStreamClient in project rest.li by linkedin.
the class TestHttpNettyStreamClient method testShutdownStuckInPool.
@Test
public void testShutdownStuckInPool() throws InterruptedException, ExecutionException, TimeoutException {
// Test that shutdown works when the outstanding request is stuck in the pool waiting for a channel
HttpNettyStreamClient client = new HttpNettyStreamClient(new NoCreations(_scheduler), _scheduler, 60000, 1);
RestRequest r = new RestRequestBuilder(URI.create("http://some.host/")).build();
FutureCallback<StreamResponse> futureCallback = new FutureCallback<>();
client.streamRequest(Messages.toStreamRequest(r), new RequestContext(), new HashMap<>(), new TransportCallbackAdapter<>(futureCallback));
FutureCallback<None> shutdownCallback = new FutureCallback<>();
client.shutdown(shutdownCallback);
shutdownCallback.get(30, TimeUnit.SECONDS);
try {
futureCallback.get(30, TimeUnit.SECONDS);
Assert.fail("get should have thrown exception");
} catch (ExecutionException e) {
verifyCauseChain(e, RemoteInvocationException.class, TimeoutException.class);
}
}
Aggregations