RFR: 8326568: jdk/test/com/sun/net/httpserver/bugs/B6431193.java should use try-with-resource and try-finally

Jaikiran Pai jpai at openjdk.org
Mon Apr 1 07:33:32 UTC 2024


On Wed, 27 Mar 2024 14:58:48 GMT, Darragh Clarke <dclarke at openjdk.org> wrote:

> Currently this test occasionally doesn't cleanup between runs, sometimes not stopping the server or leaving Streams open
> 
> Changes:
> - Use try-with-resources to ensure streams close.
> - Use try-finally to make sure the server stops before the test exits.
> 
> I ran tiers 1-3 and ran this specific test on repeat and everything seems stable after the changes

test/jdk/com/sun/net/httpserver/bugs/B6431193.java line 61:

> 59:                     os.write(response.getBytes());
> 60:                     os.close();
> 61:                     error = Thread.currentThread().isDaemon();

Hello Darragh, since we are updating this test, perhaps we should rename that variable to be a bit more precise? Looking at the history of this test, it was introduced to verify that the HTTP request was handled on the server side in a non-daemon thread. So perhaps rename that field to `handlerIsDaemon`? Then, the place where we assert this value, perhaps change it to:



if (handlerIsDaemon) {
    throw new RuntimeException ("request was handled by a daemon thread");
}

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

PR Review Comment: https://git.openjdk.org/jdk/pull/18514#discussion_r1546050907


More information about the net-dev mailing list