Return-Path: Delivered-To: apmail-geronimo-scm-archive@www.apache.org Received: (qmail 46838 invoked from network); 18 May 2006 01:03:31 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 18 May 2006 01:03:31 -0000 Received: (qmail 66779 invoked by uid 500); 18 May 2006 01:03:31 -0000 Delivered-To: apmail-geronimo-scm-archive@geronimo.apache.org Received: (qmail 66744 invoked by uid 500); 18 May 2006 01:03:31 -0000 Mailing-List: contact scm-help@geronimo.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@geronimo.apache.org List-Id: Delivered-To: mailing list scm@geronimo.apache.org Received: (qmail 66733 invoked by uid 99); 18 May 2006 01:03:30 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 17 May 2006 18:03:30 -0700 X-ASF-Spam-Status: No, hits=0.6 required=10.0 tests=NO_REAL_NAME X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [140.211.166.113] (HELO eris.apache.org) (140.211.166.113) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 17 May 2006 18:03:29 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id CE2C61A9835; Wed, 17 May 2006 18:03:09 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r407422 - in /geronimo/branches/1.1/applications: console-core/src/java/org/apache/geronimo/console/core/security/ console-core/src/java/org/apache/geronimo/console/core/system/serverinfo/ console-standard/src/java/org/apache/geronimo/conso... Date: Thu, 18 May 2006 01:03:09 -0000 To: scm@geronimo.apache.org From: jsisson@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20060518010309.CE2C61A9835@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: jsisson Date: Wed May 17 18:03:08 2006 New Revision: 407422 URL: http://svn.apache.org/viewvc?rev=407422&view=rev Log: GERONIMO-2032 - [console] Some input and output streams are not closed in finally blocks Modified: geronimo/branches/1.1/applications/console-core/src/java/org/apache/geronimo/console/core/security/PropertiesLoginModuleManager.java geronimo/branches/1.1/applications/console-core/src/java/org/apache/geronimo/console/core/system/serverinfo/ServerConstants.java geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/jmsmanager/wizard/JMSProviderData.java geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/securitymanager/realm/MasterLoginModuleInfo.java Modified: geronimo/branches/1.1/applications/console-core/src/java/org/apache/geronimo/console/core/security/PropertiesLoginModuleManager.java URL: http://svn.apache.org/viewvc/geronimo/branches/1.1/applications/console-core/src/java/org/apache/geronimo/console/core/security/PropertiesLoginModuleManager.java?rev=407422&r1=407421&r2=407422&view=diff ============================================================================== --- geronimo/branches/1.1/applications/console-core/src/java/org/apache/geronimo/console/core/security/PropertiesLoginModuleManager.java (original) +++ geronimo/branches/1.1/applications/console-core/src/java/org/apache/geronimo/console/core/security/PropertiesLoginModuleManager.java Wed May 17 18:03:08 2006 @@ -19,6 +19,7 @@ import java.io.File; import java.io.FileOutputStream; +import java.io.InputStream; import java.io.IOException; import java.io.OutputStream; import java.net.URL; @@ -58,42 +59,78 @@ private void refreshUsers() { users.clear(); + InputStream in = null; try { - users.load(serverInfo.resolve(getUsersURI()).toURL().openStream()); + in = serverInfo.resolve(getUsersURI()).toURL().openStream(); + users.load(in); } catch (Exception e) { throw new GeronimoSecurityException(e); + } finally { + if (in != null) { + try { + in.close(); + } catch (IOException ignored) { + // ignored + } + } } } private void refreshGroups() throws GeronimoSecurityException { groups.clear(); + InputStream in = null; try { - groups - .load(serverInfo.resolve(getGroupsURI()).toURL() - .openStream()); + in = serverInfo.resolve(getGroupsURI()).toURL().openStream(); + groups.load(in); } catch (Exception e) { throw new GeronimoSecurityException(e); + } finally { + if (in != null) { + try { + in.close(); + } catch (IOException ignored) { + // ignored + } + } } } public String[] getUsers() throws GeronimoSecurityException { users.clear(); + InputStream in = null; try { - users.load(serverInfo.resolve(getUsersURI()).toURL().openStream()); + in = serverInfo.resolve(getUsersURI()).toURL().openStream(); + users.load(in); } catch (Exception e) { throw new GeronimoSecurityException(e); + } finally { + if (in != null) { + try { + in.close(); + } catch (IOException ignored) { + // ignored + } + } } return (String[]) users.keySet().toArray(new String[0]); } public String[] getGroups() throws GeronimoSecurityException { groups.clear(); + InputStream in = null; try { - groups - .load(serverInfo.resolve(getGroupsURI()).toURL() - .openStream()); + in = serverInfo.resolve(getGroupsURI()).toURL().openStream(); + groups.load(in); } catch (Exception e) { throw new GeronimoSecurityException(e); + } finally { + if (in != null) { + try { + in.close(); + } catch (IOException ignored) { + // ignored + } + } } return (String[]) groups.keySet().toArray(new String[0]); } @@ -226,23 +263,28 @@ } private void store(Properties props, URL url) throws Exception { - OutputStream out; + OutputStream out = null; try { - URLConnection con = url.openConnection(); - con.setDoOutput(true); - out = con.getOutputStream(); - } catch (Exception e) { - if ("file".equalsIgnoreCase(url.getProtocol()) && e instanceof UnknownServiceException) { - out = new FileOutputStream(new File(url.getFile())); - } else { - throw e; + try { + URLConnection con = url.openConnection(); + con.setDoOutput(true); + out = con.getOutputStream(); + } catch (Exception e) { + if ("file".equalsIgnoreCase(url.getProtocol()) && e instanceof UnknownServiceException) { + out = new FileOutputStream(new File(url.getFile())); + } else { + throw e; + } + } + props.store(out, null); + } finally { + if (out != null) { + try { + out.close(); + } catch (IOException ignored) { + // ignored + } } - } - props.store(out, null); - try { - out.close(); - } catch (IOException ie) { - // Ignore } } Modified: geronimo/branches/1.1/applications/console-core/src/java/org/apache/geronimo/console/core/system/serverinfo/ServerConstants.java URL: http://svn.apache.org/viewvc/geronimo/branches/1.1/applications/console-core/src/java/org/apache/geronimo/console/core/system/serverinfo/ServerConstants.java?rev=407422&r1=407421&r2=407422&view=diff ============================================================================== --- geronimo/branches/1.1/applications/console-core/src/java/org/apache/geronimo/console/core/system/serverinfo/ServerConstants.java (original) +++ geronimo/branches/1.1/applications/console-core/src/java/org/apache/geronimo/console/core/system/serverinfo/ServerConstants.java Wed May 17 18:03:08 2006 @@ -17,6 +17,7 @@ package org.apache.geronimo.console.core.system.serverinfo; +import java.io.InputStream; import java.util.Properties; public class ServerConstants { @@ -91,12 +92,26 @@ */ static { Properties versionInfo = new Properties(); + InputStream in = ServerConstants.class.getClassLoader() + .getResourceAsStream(PROPERTIES_FILE); + if(in == null) { + throw new ExceptionInInitializerError(new Exception( + "Unable to locate geronimo-version.properties")); + } + try { - versionInfo.load(ServerConstants.class.getClassLoader() - .getResourceAsStream(PROPERTIES_FILE)); + versionInfo.load(in); } catch (java.io.IOException e) { throw new ExceptionInInitializerError(new Exception( "Could not load geronimo-version.properties", e)); + } finally { + if (in != null) { + try { + in.close(); + } catch (java.io.IOException ignored) { + // ignore + } + } } VERSION = versionInfo.getProperty("version"); if (VERSION == null || VERSION.length() == 0) { Modified: geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/jmsmanager/wizard/JMSProviderData.java URL: http://svn.apache.org/viewvc/geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/jmsmanager/wizard/JMSProviderData.java?rev=407422&r1=407421&r2=407422&view=diff ============================================================================== --- geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/jmsmanager/wizard/JMSProviderData.java (original) +++ geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/jmsmanager/wizard/JMSProviderData.java Wed May 17 18:03:08 2006 @@ -353,9 +353,15 @@ Properties props = new Properties(); try { props.load(in); - in.close(); } catch (IOException e) { log.error("Unable to read JMS provider properties file", e); + } finally { + // load could fail, ensure stream is closed. + try { + in.close(); + } catch (IOException ignore) { + // ignore + } } Set set = new HashSet(); // Find the names of the provider entries Modified: geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/securitymanager/realm/MasterLoginModuleInfo.java URL: http://svn.apache.org/viewvc/geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/securitymanager/realm/MasterLoginModuleInfo.java?rev=407422&r1=407421&r2=407422&view=diff ============================================================================== --- geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/securitymanager/realm/MasterLoginModuleInfo.java (original) +++ geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/securitymanager/realm/MasterLoginModuleInfo.java Wed May 17 18:03:08 2006 @@ -100,9 +100,14 @@ Properties props = new Properties(); try { props.load(in); - in.close(); } catch (IOException e) { log.error("Unable to read login module properties file", e); + } finally { + try { + in.close(); + } catch (java.io.IOException ignored) { + // ignore + } } for (Iterator it = props.keySet().iterator(); it.hasNext();) { String key = (String) it.next();