RFR: CODETOOLS-7902217: use try-with-resources where possible
dmitry.bessonov at oracle.com
dmitry.bessonov at oracle.com
Fri Jul 13 21:44:14 UTC 2018
On 13/07/2018 19:17, Jonathan Gibbons wrote:
>
>
> On 07/13/2018 10:30 AM, dmitry.bessonov at oracle.com wrote:
>> Please review the following fix related to Automatic Resource
>> Management applied to JTHarness code base.
>>
>> JBS: https://bugs.openjdk.java.net/browse/CODETOOLS-7902217
>> Webrev: http://cr.openjdk.java.net/~dbessono/7902217/webrev/
>>
>> dmitry
>
> Generally good.
>
> As always, there's more that can be done:
>
> Lots of places where you could use Files.new* API. E.g. lines like this
>
> 489 try (Writer writer = new BufferedWriter(new
> OutputStreamWriter(new FileOutputStream(index), StandardCharsets.UTF_8))) {
>
>
>
> There are also some potential sites that were not caught by the IDE,
> such as in Desktop.java and ConfigManager.java
>
> 971 try (FileInputStream fis = new FileInputStream(file);
> 972 InputStream in = new BufferedInputStream(fis)) {
> 973 Properties props = new Properties();
> 974 props.load(in);
> 975 in.close();
> 976 return props;
> 977 }
Applied try-with-resources more extensively and cleaned up some
double-closing:
JBS: https://bugs.openjdk.java.net/browse/CODETOOLS-7902218
Webrev: http://cr.openjdk.java.net/~dbessono/7902218/webrev/
dmitry
>
>
> -- Jon
More information about the jtharness-dev
mailing list