On Fri, 3 Feb 2023 17:58:28 GMT, Darragh Clarke <[email protected]> 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.
src/jdk.httpserver/share/classes/sun/net/httpserver/ServerImpl.java line 969:
> 967:
> 968: idleConnectionLock.lock();
> 969: if (idleConnections.size() >= MAX_IDLE_CONNECTIONS) {
Just a general point here is that you probably should use try-finally and do
the unlock in the finally block, just in case something between lock and unlock
throws or the control flow is changed for some reason, like an early return.
-------------
PR: https://git.openjdk.org/jdk/pull/12413