FELIX-1877: karaf.main.BootstrapLogManager possible resource leak and ignored exception in open method

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@884480 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/karaf/main/src/main/java/org/apache/felix/karaf/main/BootstrapLogManager.java b/karaf/main/src/main/java/org/apache/felix/karaf/main/BootstrapLogManager.java
index bde0b98..f931feb 100644
--- a/karaf/main/src/main/java/org/apache/felix/karaf/main/BootstrapLogManager.java
+++ b/karaf/main/src/main/java/org/apache/felix/karaf/main/BootstrapLogManager.java
@@ -50,10 +50,20 @@
             log = new File(filename);
         } else {
             // Make a best effort to log to the default file appender configured for log4j
+            FileInputStream fis = null;
             try {
-                props.load(new FileInputStream("../etc/org.ops4j.pax.logging.cfg"));
+                fis = new FileInputStream("../etc/org.ops4j.pax.logging.cfg");
+                props.load(fis);
             } catch (IOException e) {
                 props.setProperty("log4j.appender.out.file", "${karaf.base}/data/log/karaf.log");
+            } finally {
+                if (fis != null) { 
+                    try {
+                        fis.close(); 
+                    } catch (IOException ioe) {
+                        ioe.printStackTrace();
+                    }
+                }
             }
             filename = Main.substVars(props.getProperty("log4j.appender.out.file"),"log4j.appender.out.file", null, null);
             log = new File(filename);
@@ -87,7 +97,11 @@
 
         private void open (File logfile, boolean append) throws IOException {
             if (!logfile.getParentFile().exists()) {
-                logfile.getParentFile().mkdirs();
+                try {
+                    logfile.getParentFile().mkdirs();
+                } catch (SecurityException se) {
+                    throw new IOException(se.getMessage());
+                }
             }
             FileOutputStream fout = new FileOutputStream(logfile, append);
             BufferedOutputStream out = new BufferedOutputStream(fout);
@@ -104,4 +118,4 @@
     }
 
 
-}
\ No newline at end of file
+}