RFR: CODETOOLS-7902217: use try-with-resources where possible
Jonathan Gibbons
jonathan.gibbons at oracle.com
Fri Jul 13 18:17:19 UTC 2018
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 }
-- Jon
More information about the jtharness-dev
mailing list