Skip to content

Commit b142fa7

Browse files
author
oleksiys
committed
[1.9.x] + fix GrizzlyConnectionPoolTest
related to AsyncHttpClient#720
1 parent 02ceb33 commit b142fa7

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

src/main/java/com/ning/http/client/providers/grizzly/GrizzlyAsyncHttpProvider.java

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -248,17 +248,15 @@ public void updated(final Connection c) {
248248

249249
try {
250250
connectionManager.doAsyncTrackedConnection(request, future, connectHandler);
251+
} catch (IOException ioe) {
252+
abort(future, ioe);
253+
} catch (RuntimeException re) {
254+
abort(future, re);
251255
} catch (Exception e) {
252-
if (e instanceof RuntimeException) {
253-
abort(future, e);
254-
} else if (e instanceof IOException) {
255-
abort(future, e);
256-
} else {
257-
if (LOGGER.isWarnEnabled()) {
258-
LOGGER.warn(e.toString(), e);
259-
abort(future, e);
260-
}
256+
if (LOGGER.isWarnEnabled()) {
257+
LOGGER.warn(e.toString(), e);
261258
}
259+
abort(future, e);
262260
}
263261

264262
return future;

src/test/java/com/ning/http/client/async/grizzly/GrizzlyConnectionPoolTest.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2012 Sonatype, Inc. All rights reserved.
2+
* Copyright (c) 2012-2014 Sonatype, Inc. All rights reserved.
33
*
44
* This program is licensed to you under the Apache License Version 2.0,
55
* and you may not use this file except in compliance with the Apache License Version 2.0.
@@ -17,7 +17,6 @@
1717
import static org.testng.Assert.assertNotNull;
1818
import static org.testng.Assert.fail;
1919

20-
import java.io.IOException;
2120
import java.util.concurrent.TimeUnit;
2221

2322
import com.ning.http.client.ListenableFuture;
@@ -28,6 +27,7 @@
2827
import com.ning.http.client.Response;
2928
import com.ning.http.client.async.ConnectionPoolTest;
3029
import com.ning.http.client.async.ProviderUtil;
30+
import java.util.concurrent.ExecutionException;
3131

3232
public class GrizzlyConnectionPoolTest extends ConnectionPoolTest {
3333

@@ -50,9 +50,10 @@ public void testMaxTotalConnectionsException() {
5050
}
5151
try {
5252
client.prepareConnect(url).execute().get();
53-
} catch (IOException ioe) {
54-
assertNotNull(ioe);
55-
assertEquals("Max connections exceeded", ioe.getMessage());
53+
} catch (ExecutionException ee) {
54+
final Throwable cause = ee.getCause();
55+
assertNotNull(cause);
56+
assertEquals("Max connections exceeded", cause.getMessage());
5657
} catch (Exception e) {
5758
fail("Unexpected exception thrown.", e);
5859
}

0 commit comments

Comments
 (0)