RFR: 8300268 : ServerImpl allows too many idle connections when using sun.net.httpserver.maxIdleConnections [v2]

Daniel Fuchs dfuchs at openjdk.org
Tue Feb 7 15:15:12 UTC 2023


On Tue, 7 Feb 2023 14:49:27 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.
>
> Darragh Clarke has updated the pull request incrementally with two additional commits since the last revision:
> 
>  - use right boolean
>  - addressed comment and made test less strict

src/jdk.httpserver/share/classes/sun/net/httpserver/ServerImpl.java line 969:

> 967: 
> 968:         try {
> 969:             idleConnectionLock.lock();

The lock should be outside of the try { } finally { } block: if lock() fails, then the lock hasn't been acquired and therefore you shouldn't try to release it.

-------------

PR: https://git.openjdk.org/jdk/pull/12413


More information about the net-dev mailing list