Bug 721117

Summary: Unsatisfied obligation to close OutputStream in Apache plug-in
Product: [Other] RHQ Project Reporter: Mike Foley <mfoley>
Component: PluginsAssignee: Robert Buck <rbuck>
Status: CLOSED CURRENTRELEASE QA Contact: Mike Foley <mfoley>
Severity: medium Docs Contact:
Priority: medium    
Version: 4.1CC: hrupp
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: All   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-02-07 19:22:13 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

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