RFR: 8300268 : ServerImpl allows too many idle connections when using sun.net.httpserver.maxIdleConnections
Darragh Clarke
duke at openjdk.org
Tue Feb 7 14:53:58 UTC 2023
On Fri, 3 Feb 2023 17:58:28 GMT, Darragh Clarke <duke at openjdk.org> wrote:
> Currently there is a race condition that can allow for too many 'idleConnections' in `ServerImpl`
>
> This PR adds a lock to make sure only one connection can be marked Idle at a time as well as a test that consistently failed before the change but which now passes.
I pushed some changes there, firstly added the Try/Finally that Alan suggested, secondly changed to use `boolean` instead of `Boolean`, finally updated the test to pass as long as the number of connections doesn't exceed the maximum instead of needing the idleConnectionCount to equal it as it is possible for some idle connections to close before the test is finished.
I ran the test across a few machines with and without my change to see if it was just my local machine that consistently failed without the change.
Before the change the test passed around 45% of the time usually with a 5th idle connection being allowed when the limit was 4 causing the failures.
With the change the pass rate jumped to 100%
-------------
PR: https://git.openjdk.org/jdk/pull/12413
More information about the net-dev
mailing list