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 218094 - Close FileInputStream, FileOutputStream, Statement and ResultSet
Summary: Close FileInputStream, FileOutputStream, Statement and ResultSet
Status: RESOLVED FIXED
Alias: None
Product: ide
Classification: Unclassified
Component: Code (show other bugs)
Version: 7.3
Hardware: All All
: P2 normal (vote)
Assignee: Tomas Hurka
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-09-11 06:30 UTC by Tomas Hurka
Modified: 2012-09-22 02:17 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Proposed patch (3.82 KB, application/octet-stream)
2012-09-11 06:30 UTC, Tomas Hurka
Details
Proposed patch (3.82 KB, patch)
2012-09-11 06:31 UTC, Tomas Hurka
Details | Diff
Proposed patch (69.18 KB, patch)
2012-09-11 06:32 UTC, Tomas Hurka
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tomas Hurka 2012-09-11 06:30:26 UTC
Created attachment 124129 [details]
Proposed patch

It is better to close FileInputStream, FileOutputStream, Statement and ResultSet directly and do not rely on their finalizers. I run Findbugs against netbeans main repository to find cases, where the resources are not closed properly. Attached patch fixes all the cases (except test sources) found by Findbugs. Please review the changes.
Comment 1 Tomas Hurka 2012-09-11 06:31:03 UTC
Created attachment 124130 [details]
Proposed patch
Comment 2 Tomas Hurka 2012-09-11 06:32:54 UTC
Created attachment 124131 [details]
Proposed patch
Comment 3 Jaroslav Tulach 2012-09-11 13:00:45 UTC
libs/freemarker fix seems OK.
Arch.java change is OK.
ParseManifest.java is OK.
junit/Manager.java was probably wrong to begin with - it should not swallow the exception and at least report it.
Comment 4 Jaroslav Havlin 2012-09-12 08:53:52 UTC
db.* fixes are OK. Thank you.
Comment 5 Ondrej Vrabec 2012-09-12 09:56:04 UTC
git/* fixes are OK. The git client closes the stream itself but closing a FOS twice does not do any harm.
Comment 6 Tomas Zezula 2012-09-17 14:41:38 UTC
All the patches for Java
Comment 7 Tomas Zezula 2012-09-17 14:43:03 UTC
All the patches for Java & Editor are OK.
Here is the list of review classes:

j2me.cdc.project/src/org/netbeans/modules/j2me/cdc/project/ui/wizards/ImportCDCProjectWizardIterator.java
java.hints.test/src/org/netbeans/modules/java/hints/test/api/HintTest.java
javafx2.scenebuilder/src/org/netbeans/modules/javafx2/scenebuilder/impl/SBHomeFactory.java
mobility.plugins.mpowerplayer/src/org/netbeans/modules/mobility/plugins/mpowerplayer/MPowerPlayerPlatformConfigurator.java
o.apache.tools.ant.module.docs/antsrc/MakeManual.java
Comment 8 Martin Fousek 2012-09-18 08:05:46 UTC
coherence.*, web.core fixes are OK
Comment 9 Denis Anisimov 2012-09-18 08:17:38 UTC
websvc.* fixes are OK.
Comment 10 Petr Hejl 2012-09-18 08:32:02 UTC
Jboss seems to be ok. Tomasi please take a look at j2ee.sun.appsrv*
Comment 11 Ondrej Vrabec 2012-09-18 09:33:59 UTC
subversion.* OK
jira...AttachmentsPanel.java - OK, although the stream is always closed inside the called method - it's noted in its javadoc. But closing twice does no harm
bugtracking.* - OK
bugzilla.* - OK
Thanks, Tomasi
Comment 12 Tomas Hurka 2012-09-20 12:35:01 UTC
Thanks a lot for review.
Fixed in profiler-main

changeset:   233709:12e78ec41d36
user:        Tomas Hurka <thurka@netbeans.org>
date:        Thu Sep 20 14:33:52 2012 +0200
summary:     bugfix #218094, close open resources detected by findbugs
Comment 13 Quality Engineering 2012-09-22 02:17:31 UTC
Integrated into 'main-golden', will be available in build *201209220001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/12e78ec41d36
User: Tomas Hurka <thurka@netbeans.org>
Log: bugfix #218094, close open resources detected by findbugs