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.

Bug 207480 - Refactoring to wrap try-with-resources with an exception breaks the code.
Summary: Refactoring to wrap try-with-resources with an exception breaks the code.
Status: RESOLVED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Hints (show other bugs)
Version: 7.0
Hardware: All All
: P3 normal (vote)
Assignee: Jan Lahoda
URL:
Keywords:
: 75741 137713 (view as bug list)
Depends on:
Blocks:
 
Reported: 2012-01-18 17:39 UTC by Salamander
Modified: 2013-02-08 20:30 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Salamander 2012-01-18 17:39:50 UTC
try (final BufferedReader br = new BufferedReader(new FileReader("misc.txt"), 1_000_000)) {
  ... stuff...
}

Choosing to add an exception (IOException in my case) breaks the code.
I believe the refactoring is not "try-with-resources aware" yet.


Product Version = NetBeans IDE Dev (Build 201201050601)
Operating System = Mac OS X version 10.7.2 running on x86_64
Java; VM; Vendor = 1.6.0_29
Runtime = Java HotSpot(TM) 64-Bit Server VM 20.4-b02-402
Comment 1 Jan Lahoda 2012-12-13 19:20:02 UTC
Fixed by added a new "Add catch Clause(s)" fix - the "Surround Block" will no longer be proposed to this code:
http://hg.netbeans.org/jet-main/rev/edbcc4f9da7d

Fixing formatting after adding the very first catch clause:
http://hg.netbeans.org/jet-main/rev/89f350f83c64
Comment 2 Quality Engineering 2012-12-14 02:41:59 UTC
Integrated into 'main-golden', will be available in build *201212140001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/edbcc4f9da7d
User: Jan Lahoda <jlahoda@netbeans.org>
Log: #207480: better handling of surround with try-catch: rather than showing Surround with block and then adding a catch into a surrounding try-catch, show directly 'Add catch Clause'
Comment 3 markiewb 2013-02-08 19:59:30 UTC
*** Bug 137713 has been marked as a duplicate of this bug. ***
Comment 4 markiewb 2013-02-08 20:30:29 UTC
*** Bug 75741 has been marked as a duplicate of this bug. ***