RFR: 8326568: jdk/test/com/sun/net/httpserver/bugs/B6431193.java should use try-with-resource and try-finally
Daniel Fuchs
dfuchs at openjdk.org
Wed Mar 27 19:42:21 UTC 2024
On Wed, 27 Mar 2024 16:35:35 GMT, Darragh Clarke <dclarke at openjdk.org> wrote:
>> 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?
Depends on how much data the test actually sends. If it's a small amount readAllBytes is fine.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/18514#discussion_r1541925035
More information about the net-dev
mailing list