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 <simone.bordet@gmail.com>
This commit is contained in:
Simone Bordet 2020-07-09 16:18:15 +02:00
parent 6844c9362d
commit 94956d6e8b
2 changed files with 3 additions and 4 deletions

View File

@ -132,10 +132,9 @@ public abstract class AbstractConnectionPool implements ConnectionPool, Dumpable
protected Connection acquire(boolean create) protected Connection acquire(boolean create)
{ {
Connection connection = activate(); Connection connection = activate();
if (connection == null) if (connection == null && create)
{ {
if (create) tryCreate(destination.getQueuedRequestCount());
tryCreate(destination.getQueuedRequestCount());
connection = activate(); connection = activate();
} }
return connection; return connection;

View File

@ -176,6 +176,7 @@ public class MaxConcurrentStreamsTest extends AbstractTest
@Override @Override
public void onSettings(Session session, SettingsFrame frame) public void onSettings(Session session, SettingsFrame frame)
{ {
super.onSettings(session, frame);
// Send another request to simulate a request being // Send another request to simulate a request being
// sent concurrently with connection establishment. // sent concurrently with connection establishment.
// Sending this request will trigger the creation of // Sending this request will trigger the creation of
@ -200,7 +201,6 @@ public class MaxConcurrentStreamsTest extends AbstractTest
} }
}); });
} }
super.onSettings(session, frame);
} }
}, promise, context); }, promise, context);
} }