commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject svn commit: r1765341 - in /commons/proper/logging/trunk/src: changes/changes.xml main/java/org/apache/commons/logging/LogFactory.java main/java/org/apache/commons/logging/impl/SimpleLog.java
Date Mon, 17 Oct 2016 16:56:41 GMT
Author: ggregory
Date: Mon Oct 17 16:56:41 2016
New Revision: 1765341

URL: http://svn.apache.org/viewvc?rev=1765341&view=rev
Log:
[LOGGING-163] BufferedReader is not closed properly.

Modified:
    commons/proper/logging/trunk/src/changes/changes.xml
    commons/proper/logging/trunk/src/main/java/org/apache/commons/logging/LogFactory.java
    commons/proper/logging/trunk/src/main/java/org/apache/commons/logging/impl/SimpleLog.java

Modified: commons/proper/logging/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/logging/trunk/src/changes/changes.xml?rev=1765341&r1=1765340&r2=1765341&view=diff
==============================================================================
--- commons/proper/logging/trunk/src/changes/changes.xml (original)
+++ commons/proper/logging/trunk/src/changes/changes.xml Mon Oct 17 16:56:41 2016
@@ -44,6 +44,9 @@ The <action> type attribute can be add,u
   </properties>
   <body>
     <release version="1.2.1" date="TBD" description="This is a maintenance release containing
bug fixes. Java 1.2 or later is required.">
+      <action issue="LOGGING-163" dev="ggregory" type="fix" due-to="Kaloyan Spiridonov">
+        BufferedReader is not closed properly.
+      </action>
     </release>
     <release version="1.2" date="2014-07-11" description="This is a maintenance release
containing bug fixes. Java 1.2 or later is required.">
       <action issue="LOGGING-37" dev="tn" type="fix" due-to="Matthias Ernst,Archie Cobbs">

Modified: commons/proper/logging/trunk/src/main/java/org/apache/commons/logging/LogFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/logging/trunk/src/main/java/org/apache/commons/logging/LogFactory.java?rev=1765341&r1=1765340&r2=1765341&view=diff
==============================================================================
--- commons/proper/logging/trunk/src/main/java/org/apache/commons/logging/LogFactory.java
(original)
+++ commons/proper/logging/trunk/src/main/java/org/apache/commons/logging/LogFactory.java
Mon Oct 17 16:56:41 2016
@@ -539,8 +539,12 @@ public abstract class LogFactory {
                         rd = new BufferedReader(new InputStreamReader(is));
                     }
 
-                    String factoryClassName = rd.readLine();
-                    rd.close();
+                    String factoryClassName;
+                    try {
+                        factoryClassName = rd.readLine();
+                    } finally {
+                        rd.close();
+                    }
 
                     if (factoryClassName != null && ! "".equals(factoryClassName))
{
                         if (isDiagnosticsEnabled()) {

Modified: commons/proper/logging/trunk/src/main/java/org/apache/commons/logging/impl/SimpleLog.java
URL: http://svn.apache.org/viewvc/commons/proper/logging/trunk/src/main/java/org/apache/commons/logging/impl/SimpleLog.java?rev=1765341&r1=1765340&r2=1765341&view=diff
==============================================================================
--- commons/proper/logging/trunk/src/main/java/org/apache/commons/logging/impl/SimpleLog.java
(original)
+++ commons/proper/logging/trunk/src/main/java/org/apache/commons/logging/impl/SimpleLog.java
Mon Oct 17 16:56:41 2016
@@ -17,6 +17,7 @@
 
 package org.apache.commons.logging.impl;
 
+import java.io.IOException;
 import java.io.InputStream;
 import java.io.Serializable;
 import java.lang.reflect.InvocationTargetException;
@@ -158,12 +159,17 @@ public class SimpleLog implements Log, S
     static {
         // Add props from the resource simplelog.properties
         InputStream in = getResourceAsStream("simplelog.properties");
-        if(null != in) {
+        if (null != in) {
             try {
                 simpleLogProps.load(in);
-                in.close();
-            } catch(java.io.IOException e) {
+            } catch (java.io.IOException e) {
                 // ignored
+            } finally {
+                try {
+                    in.close();
+                } catch (IOException e) {
+                    // ignored
+                }
             }
         }
 



Mime
View raw message