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

Darragh Clarke dclarke at openjdk.org
Wed Mar 27 16:38:24 UTC 2024


On Wed, 27 Mar 2024 15:14:00 GMT, Daniel Fuchs <dfuchs 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 81:
> 
>> 79:                     .toURL();
>> 80:             InputStream is = url.openConnection(Proxy.NO_PROXY).getInputStream();
>> 81:             read(is);
> 
> should use try-with-resource here too. `read(is)` no longer closes `is`.

Good point, looking at it again would it be worthwhile to get rid of the `read` method and just use `is.readAllBytes` in it's place?

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

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


More information about the net-dev mailing list