From 94956d6e8b625c052699cbff46713fb12b512e3c Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Thu, 9 Jul 2020 16:18:15 +0200 Subject: [PATCH] Issue #4904 - WebsocketClient creates more connections than needed. Fixed MaxConcurrentStreamsTest - it was always broken. The problem was that the call to super.onSettings(...) was done _after_ sending the request, so the connection pool was still configured with the default maxMultiplex=1024. Also fixed AbstractConnectionPool to avoid a second call to activate() if we are not trying to create a new connection. Signed-off-by: Simone Bordet --- .../org/eclipse/jetty/client/AbstractConnectionPool.java | 5 ++--- .../jetty/http2/client/http/MaxConcurrentStreamsTest.java | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/AbstractConnectionPool.java b/jetty-client/src/main/java/org/eclipse/jetty/client/AbstractConnectionPool.java index 15470cc0794..ac2b806ffa8 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/AbstractConnectionPool.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/AbstractConnectionPool.java @@ -132,10 +132,9 @@ public abstract class AbstractConnectionPool implements ConnectionPool, Dumpable protected Connection acquire(boolean create) { Connection connection = activate(); - if (connection == null) + if (connection == null && create) { - if (create) - tryCreate(destination.getQueuedRequestCount()); + tryCreate(destination.getQueuedRequestCount()); connection = activate(); } return connection; diff --git a/jetty-http2/http2-http-client-transport/src/test/java/org/eclipse/jetty/http2/client/http/MaxConcurrentStreamsTest.java b/jetty-http2/http2-http-client-transport/src/test/java/org/eclipse/jetty/http2/client/http/MaxConcurrentStreamsTest.java index 718a6b08d6e..e294d1c9585 100644 --- a/jetty-http2/http2-http-client-transport/src/test/java/org/eclipse/jetty/http2/client/http/MaxConcurrentStreamsTest.java +++ b/jetty-http2/http2-http-client-transport/src/test/java/org/eclipse/jetty/http2/client/http/MaxConcurrentStreamsTest.java @@ -176,6 +176,7 @@ public class MaxConcurrentStreamsTest extends AbstractTest @Override public void onSettings(Session session, SettingsFrame frame) { + super.onSettings(session, frame); // Send another request to simulate a request being // sent concurrently with connection establishment. // Sending this request will trigger the creation of @@ -200,7 +201,6 @@ public class MaxConcurrentStreamsTest extends AbstractTest } }); } - super.onSettings(session, frame); } }, promise, context); }