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

Jaikiran Pai jpai at openjdk.org
Tue Apr 2 15:04:13 UTC 2024


On Tue, 2 Apr 2024 11:55:12 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
>
> Darragh Clarke has updated the pull request incrementally with one additional commit since the last revision:
> 
>   implemented feedback

Darragh, one other thing - I haven't paid close attention to this test, so can't say for certain - are we sure that when the test code reaches the place where we assert on `handlerIsDaemon` field, the `MyHandler.handle()` was indeed invoked? A quick look at that test didn't convince me that this code:


InputStream is = url.openConnection(Proxy.NO_PROXY).getInputStream();
            read (is);

is enough to guarantee that the handler was invoked.

I would have looked at the test code and the HttpURLConnection implementation myself, but I need to head out now.

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

PR Comment: https://git.openjdk.org/jdk/pull/18514#issuecomment-2032290965


More information about the net-dev mailing list