This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
I made this small snippet to demonstrate this problem: public static void main(final String[] args) { final char[] buffer = new char[100]; try { final FileReader reader = new FileReader("test.txt"); reader.read(buffer); reader.close(); } catch (IOException exception) { exception.printStackTrace(); } } When I use "Convert to try-with-resources", I get: public static void main(final String[] args) { final char[] buffer = new char[100]; try { try (FileReader reader = new FileReader("test.txt")) { reader.read(buffer); } } catch (IOException exception) { exception.printStackTrace(); } } I don't see why it created a nested try-with-resources block instead of adding the resources to the existing try block, like this: public static void main(final String[] args) { final char[] buffer = new char[100]; try (FileReader reader = new FileReader("test.txt")) { reader.read(buffer); } catch (IOException exception) { exception.printStackTrace(); } }
Feel free to reassign back.
Fixed in jet-main#8e32a189adc1
Integrated into 'main-silver', will be available in build *201504120001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main-silver/rev/8e32a189adc1 User: Svata Dedic <sdedic@netbeans.org> Log: #197884: existing pure try block can be converted to try-with-resources