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 142242 - try-catch hint for block generates strange code
Summary: try-catch hint for block generates strange code
Status: RESOLVED DUPLICATE of bug 142199
Alias: None
Product: editor
Classification: Unclassified
Component: Hints & Annotations (show other bugs)
Version: 6.x
Hardware: All All
: P2 blocker (vote)
Assignee: issues@editor
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-07-30 15:02 UTC by Lukas Hasik
Modified: 2008-07-31 08:07 UTC (History)
1 user (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 Lukas Hasik 2008-07-30 15:02:28 UTC
Product Version: NetBeans IDE Dev (Build 080730)
Java: 1.5.0_14; Java HotSpot(TM) Client VM 1.5.0_14-b03
System: Windows XP version 5.1 running on x86; Cp1252; en_US (nb)
Userdir: F:\hg\main\nbbuild\testuserdir

1, I have code like
        FileInputStream fis = new FileInputStream(filename);
        int x = fis.available();
        byte b[] = new byte[x];
        fis.read(b);
        String content = new String(b);
        System.out.println(content);
2, use hint "Surround \block with try-catch" on the first line

-> result looks strange, why there is the "try { fis = null" ?

        FileInputStream fis = null;
        try {
            fis = null;
        try {
            fis = new FileInputStream(filename);
            
            int x = fis.available();
            
            byte[] b b = new byte[x];
            
            fis.read(b);
            String content = new String(b);
            System.out.println(content);
        } catch (FileNotFoundException ex) {
            Exceptions.printStackTrace(ex);
        } finally {
            try {
                fis.close();
            } catch (IOException ex) {
                Exceptions.printStackTrace(ex);
            }
        }
            String content = new String(b);
            System.out.println(content);
        } catch (FileNotFoundException ex) {
            Exceptions.printStackTrace(ex);
        } finally {
            try {
                fis.close();
            } catch (IOException ex) {
                Exceptions.printStackTrace(ex);
            }
        }
Comment 1 Marian Mirilovic 2008-07-30 15:23:41 UTC
Dup of issue 142199 ?
Comment 2 Jiri Prox 2008-07-31 08:07:22 UTC
Yes, it's dup of issue 142199. I cannot reproduce now when 142199 is fixed

*** This issue has been marked as a duplicate of 142199 ***