logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From grobme...@apache.org
Subject svn commit: r1231387 - in /logging/log4j/trunk/src: changes/changes.xml main/java/org/apache/log4j/jdbc/JDBCAppender.java
Date Fri, 13 Jan 2012 23:16:49 GMT
Author: grobmeier
Date: Fri Jan 13 23:16:48 2012
New Revision: 1231387

URL: http://svn.apache.org/viewvc?rev=1231387&view=rev
Log:
51597 JDBCAppender not closed due to SQL Exception while executing an SQL (thanks to Anurag
Agarwal)

Modified:
    logging/log4j/trunk/src/changes/changes.xml
    logging/log4j/trunk/src/main/java/org/apache/log4j/jdbc/JDBCAppender.java

Modified: logging/log4j/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/logging/log4j/trunk/src/changes/changes.xml?rev=1231387&r1=1231386&r2=1231387&view=diff
==============================================================================
--- logging/log4j/trunk/src/changes/changes.xml (original)
+++ logging/log4j/trunk/src/changes/changes.xml Fri Jan 13 23:16:48 2012
@@ -22,6 +22,7 @@
   <body>
     <release version="1.2.17" date="2010-06-99" description="Maintenance release">
        <action issue="49470">log4j 1.2.17 release preparation</action>
+       <action issue="51597" action="fix">JDBCAppender not closed due to SQL Exception
while executing an SQL (thanks to Anurag Agarwal)</action>
        <action issue="50486" action="fix">Memoryleak - org.apache.log4j.helpers.ThreadLocalMap</action>
        <action issue="43282" action="fix">Eliminate duplicates in OSGi Import-Package
directive.</action>
        <action issue="48588" action="fix">DOMConfigurator does not close input stream
when configured based on URL.</action>

Modified: logging/log4j/trunk/src/main/java/org/apache/log4j/jdbc/JDBCAppender.java
URL: http://svn.apache.org/viewvc/logging/log4j/trunk/src/main/java/org/apache/log4j/jdbc/JDBCAppender.java?rev=1231387&r1=1231386&r2=1231387&view=diff
==============================================================================
--- logging/log4j/trunk/src/main/java/org/apache/log4j/jdbc/JDBCAppender.java (original)
+++ logging/log4j/trunk/src/main/java/org/apache/log4j/jdbc/JDBCAppender.java Fri Jan 13 23:16:48
2012
@@ -216,13 +216,12 @@ public class JDBCAppender extends org.ap
 
         stmt = con.createStatement();
         stmt.executeUpdate(sql);
-    } catch (SQLException e) {
-       if (stmt != null)
-	     stmt.close();
-       throw e;
+    } finally {
+        if(stmt != null) {
+            stmt.close();
+        }
+        closeConnection(con);
     }
-    stmt.close();
-    closeConnection(con);
 
     //System.out.println("Execute: " + sql);
   }
@@ -284,15 +283,16 @@ public class JDBCAppender extends org.ap
     //Do the actual logging
     removes.ensureCapacity(buffer.size());
     for (Iterator i = buffer.iterator(); i.hasNext();) {
+      LoggingEvent logEvent = (LoggingEvent)i.next();
       try {
-        LoggingEvent logEvent = (LoggingEvent)i.next();
 	    String sql = getLogStatement(logEvent);
 	    execute(sql);
-        removes.add(logEvent);
       }
       catch (SQLException e) {
 	    errorHandler.error("Failed to excute sql", e,
 			   ErrorCode.FLUSH_FAILURE);
+      } finally {
+        removes.add(logEvent);
       }
     }
     



Mime
View raw message