Bug 721117 - Unsatisfied obligation to close OutputStream in Apache plug-in
Summary: Unsatisfied obligation to close OutputStream in Apache plug-in
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: RHQ Project
Classification: Other
Component: Plugins
Version: 4.1
Hardware: All
OS: All
medium
medium vote
Target Milestone: ---
: ---
Assignee: Robert Buck
QA Contact: Mike Foley
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2011-07-13 19:09 UTC by Mike Foley
Modified: 2012-02-07 19:22 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2012-02-07 19:22:13 UTC


Attachments (Terms of Use)

Description Mike Foley 2011-07-13 19:09:08 UTC
Description of problem:  An output stream is opened, but not closed in the Apache plug-in.  Specifically, org.rhq.plugins.apache.parser.saveFile()


Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
1.
2.
3.
  
Actual results:
Unsatisfied programmatic obligation to close OutputStream results in resource leaks.

Expected results:
Fufill programmatic obligation to close Outputstream to avoid resource leaks.

Additional info:
 

public void saveFile(String file,ApacheDirective dir) throws Exception{
        
        File fl = new File(file);
        if (!fl.exists())
            fl.createNewFile();
        
        OutputStream str = new FileOutputStream(fl);
        for (ApacheDirective d : dir.getChildDirectives()){
            if (dir.getFile().equals(file)){
                writeToFile(str,dir,file);
            }
        }
    }

Comment 1 Mike Foley 2011-10-06 19:05:34 UTC
bob ... u closed all streams from the coverity report en masse ...right?

Comment 2 Robert Buck 2011-10-07 13:33:17 UTC
I did, but apparently this is one that crept by me. let me fix this, this is a two second fix.

Comment 3 Robert Buck 2011-10-07 15:03:57 UTC
commit 0cf4f6b696f31e115165b826af14570a6b8a0b20
Author: Robert Buck <rbuck>
Date:   2011-10-07 11:02:43 -0400
[BZ 721117] Fix IO stream resource leak; I fixed this previously, but as I was in here I fixed a few minor issues, making it code-green.

Comment 4 Mike Foley 2012-02-07 19:22:13 UTC
changing status of VERIFIED BZs for JON 2.4.2 and JON 3.0 to CLOSED/CURRENTRELEASE


Note You need to log in before you can comment on or make changes to this bug.