Skip to content

Commit 4f9ada4

Browse files
committed
Fix test case and Grizzly impl.
1 parent 46e90de commit 4f9ada4

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

api/src/test/java/org/asynchttpclient/async/SimpleAsyncHttpClientTest.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -253,10 +253,6 @@ public void testCloseMasterInvalidDerived() throws Exception {
253253
try {
254254
derived.get().get();
255255
fail("Expected closed AHC");
256-
} catch (ExecutionException ee) {
257-
if (!(ee.getCause() instanceof IOException)) {
258-
fail("Unexpected failure: " + ee.getCause());
259-
}
260256
} catch (IOException e) {
261257
// expected
262258
}

providers/grizzly/src/main/java/org/asynchttpclient/providers/grizzly/GrizzlyAsyncHttpProvider.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,9 @@ public GrizzlyAsyncHttpProvider(final AsyncHttpClientConfig clientConfig) {
137137
public <T> ListenableFuture<T> execute(final Request request,
138138
final AsyncHandler<T> handler) throws IOException {
139139

140+
if (clientTransport.isStopped()) {
141+
throw new IOException("AsyncHttpClient has been closed.");
142+
}
140143
final ProxyServer proxy = ProxyUtils.getProxyServer(clientConfig, request);
141144
final GrizzlyResponseFuture<T> future = new GrizzlyResponseFuture<T>(this, request, handler, proxy);
142145
future.setDelegate(SafeFutureImpl.<T>create());
@@ -231,11 +234,11 @@ public <T> ListenableFuture<T> execute(final Connection c,
231234
final Request request,
232235
final AsyncHandler<T> handler,
233236
final GrizzlyResponseFuture<T> future) {
234-
Utils.addRequestInFlight(c);
235-
if (HttpTransactionContext.get(c) == null) {
236-
HttpTransactionContext.create(this, future, request, handler, c);
237-
}
238-
c.write(request, createWriteCompletionHandler(future));
237+
Utils.addRequestInFlight(c);
238+
if (HttpTransactionContext.get(c) == null) {
239+
HttpTransactionContext.create(this, future, request, handler, c);
240+
}
241+
c.write(request, createWriteCompletionHandler(future));
239242

240243
return future;
241244
}

0 commit comments

Comments
 (0)