Skip to content

Commit dd6aed0

Browse files
committed
Fix TooManyConnectionsException message and test
1 parent 41d7862 commit dd6aed0

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

client/src/main/java/org/asynchttpclient/netty/channel/exception/TooManyConnectionsException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@
1818
public class TooManyConnectionsException extends IOException {
1919

2020
public TooManyConnectionsException(int max) {
21-
super("Too many connections per host " + max);
21+
super("Too many connections: " + max);
2222
}
2323
}

client/src/main/java/org/asynchttpclient/netty/channel/exception/TooManyConnectionsPerHostException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@
1818
public class TooManyConnectionsPerHostException extends IOException {
1919

2020
public TooManyConnectionsPerHostException(int max) {
21-
super("Too many connections " + max);
21+
super("Too many connections: " + max);
2222
}
2323
}

client/src/test/java/org/asynchttpclient/channel/pool/ConnectionPoolTest.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import org.asynchttpclient.ListenableFuture;
3838
import org.asynchttpclient.RequestBuilder;
3939
import org.asynchttpclient.Response;
40+
import org.asynchttpclient.netty.channel.exception.TooManyConnectionsException;
4041
import org.asynchttpclient.test.EventCollectingHandler;
4142
import org.testng.annotations.Test;
4243

@@ -61,8 +62,8 @@ public void testMaxTotalConnections() throws Exception {
6162
}
6263
}
6364

64-
@Test(groups = "standalone")
65-
public void testMaxTotalConnectionsException() throws IOException {
65+
@Test(groups = "standalone", expectedExceptions = TooManyConnectionsException.class)
66+
public void testMaxTotalConnectionsException() throws Throwable {
6667
try (AsyncHttpClient client = asyncHttpClient(config().setKeepAlive(true).setMaxConnections(1))) {
6768
String url = getTargetUrl();
6869

@@ -83,8 +84,7 @@ public void testMaxTotalConnectionsException() throws IOException {
8384
}
8485

8586
assertNotNull(exception);
86-
assertNotNull(exception.getCause());
87-
assertEquals(exception.getCause().getMessage(), "Too many connections 1");
87+
throw exception.getCause();
8888
}
8989
}
9090

@@ -124,8 +124,8 @@ public Response onCompleted(Response response) throws Exception {
124124
}
125125
}
126126

127-
@Test(groups = "standalone")
128-
public void multipleMaxConnectionOpenTest() throws Exception {
127+
@Test(groups = "standalone", expectedExceptions = TooManyConnectionsException.class)
128+
public void multipleMaxConnectionOpenTest() throws Throwable {
129129
try (AsyncHttpClient c = asyncHttpClient(config().setKeepAlive(true).setConnectTimeout(5000).setMaxConnections(1))) {
130130
String body = "hello there";
131131

@@ -144,8 +144,7 @@ public void multipleMaxConnectionOpenTest() throws Exception {
144144
exception = ex;
145145
}
146146
assertNotNull(exception);
147-
assertNotNull(exception.getCause());
148-
assertEquals(exception.getCause().getMessage(), "Too many connections 1");
147+
throw exception.getCause();
149148
}
150149
}
151150

0 commit comments

Comments
 (0)