logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject svn commit: r1566186 - in /logging/log4j/log4j2/trunk: log4j-flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumePersistentManager.java src/changes/changes.xml
Date Sun, 09 Feb 2014 02:56:38 GMT
Author: ggregory
Date: Sun Feb  9 02:56:37 2014
New Revision: 1566186

URL: http://svn.apache.org/r1566186
Log:
<action issue="LOG4J2-532" dev="ggregory" type="update">Resource leak in Flume appender
when it cannot create a BerkeleyDB db.</action>

Modified:
    logging/log4j/log4j2/trunk/log4j-flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumePersistentManager.java
    logging/log4j/log4j2/trunk/src/changes/changes.xml

Modified: logging/log4j/log4j2/trunk/log4j-flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumePersistentManager.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumePersistentManager.java?rev=1566186&r1=1566185&r2=1566186&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumePersistentManager.java
(original)
+++ logging/log4j/log4j2/trunk/log4j-flume-ng/src/main/java/org/apache/logging/log4j/flume/appender/FlumePersistentManager.java
Sun Feb  9 02:56:37 2014
@@ -390,9 +390,8 @@ public class FlumePersistentManager exte
         @Override
         public FlumePersistentManager createManager(final String name, final FactoryData
data) {
             SecretKey secretKey = null;
-
-            Database database;
-            Environment environment;
+            Database database = null;
+            Environment environment = null;
 
             final Map<String, String> properties = new HashMap<String, String>();
             if (data.properties != null) {
@@ -402,7 +401,6 @@ public class FlumePersistentManager exte
             }
 
             try {
-
                 final File dir = new File(data.dataDir);
                 FileUtils.mkdir(dir, true);
                 final EnvironmentConfig dbEnvConfig = new EnvironmentConfig();
@@ -416,6 +414,17 @@ public class FlumePersistentManager exte
                 database = environment.openDatabase(null, name, dbConfig);
             } catch (final Exception ex) {
                 LOGGER.error("Could not create FlumePersistentManager", ex);
+                // For consistency, close database as well as environment even though it
should never happen since the
+                // database is that last thing in the block above, but this does guard against
a future line being
+                // inserted at the end that would bomb (like some debug logging).
+                if (database != null) {
+                    database.close();
+                    database = null;
+                }
+                if (environment != null) {
+                    environment.close();
+                    environment = null;
+                }
                 return null;
             }
 

Modified: logging/log4j/log4j2/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/src/changes/changes.xml?rev=1566186&r1=1566185&r2=1566186&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/src/changes/changes.xml (original)
+++ logging/log4j/log4j2/trunk/src/changes/changes.xml Sun Feb  9 02:56:37 2014
@@ -240,6 +240,9 @@
       <action issue="LOG4J2-528" dev="ggregory" type="update">
         Rename package org.apache.logging.log4j.core.appender.rolling.helper to org.apache.logging.log4j.core.appender.rolling.action.
       </action>
+      <action issue="LOG4J2-532" dev="ggregory" type="update">
+        Resource leak in Flume appender when it cannot create a BerkeleyDB db.
+      </action>
     </release>
     <release version="2.0-beta9" date="2013-09-14" description="Bug fixes and enhancements">
       <action issue="LOG4J2-317" dev="ggregory" type="update">



Mime
View raw message