jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cko...@apache.org
Subject svn commit: r1360571 - in /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core: persistence/pool/BundleDbPersistenceManager.java util/db/ConnectionHelper.java
Date Thu, 12 Jul 2012 08:06:20 GMT
Author: ckoell
Date: Thu Jul 12 08:06:20 2012
New Revision: 1360571

URL: http://svn.apache.org/viewvc?rev=1360571&view=rev
Log:
JCR-3383 Unclosed Resources in ConnectionHelper if ResultSet is null

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/pool/BundleDbPersistenceManager.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/ConnectionHelper.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/pool/BundleDbPersistenceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/pool/BundleDbPersistenceManager.java?rev=1360571&r1=1360570&r2=1360571&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/pool/BundleDbPersistenceManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/pool/BundleDbPersistenceManager.java
Thu Jul 12 08:06:20 2012
@@ -501,7 +501,7 @@ public class BundleDbPersistenceManager
             }
             failures++;
             log.error("Failed to persist ChangeLog (stacktrace on DEBUG log level), blockOnConnectionLoss
= "
-                    + blockOnConnectionLoss, lastException);
+                    + blockOnConnectionLoss + ": " + lastException);
             log.debug("Failed to persist ChangeLog", lastException);
             if (blockOnConnectionLoss || failures <= 1) { // if we're going to try again
                 try {
@@ -885,13 +885,15 @@ public class BundleDbPersistenceManager
             ResultSet rs =
                 conHelper.exec(bundleSelectSQL, getKey(id), false, 0);
             try {
-                if (rs.next()) {
+                if (rs != null && rs.next()) {
                     return readBundle(id, rs, 1);
                 } else {
                     return null;
                 }
             } finally {
-                rs.close();
+            	if (rs != null) {
+            		rs.close();
+            	}
             }
         } catch (SQLException e) {
         	String msg = "failed to read bundle (stacktrace on DEBUG log level): " + id + ":
" + e; 

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/ConnectionHelper.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/ConnectionHelper.java?rev=1360571&r1=1360570&r2=1360571&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/ConnectionHelper.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/ConnectionHelper.java
Thu Jul 12 08:06:20 2012
@@ -404,6 +404,7 @@ public class ConnectionHelper {
             }
             // Don't wrap null
             if (rs == null) {
+            	closeResources(con, stmt, rs);
                 return null;
             }
             if (inBatchMode()) {
@@ -586,7 +587,7 @@ public class ConnectionHelper {
                     } catch (SQLException e) {
                         lastException = e;
                     }
-                    log.error("Failed to execute SQL (stacktrace on DEBUG log level)", lastException);
+                    log.error("Failed to execute SQL (stacktrace on DEBUG log level): " +
lastException);
                     log.debug("Failed to execute SQL", lastException);
                     failures++;
                     if (blockOnConnectionLoss || failures <= RETRIES) { // if we're going
to try again



Mime
View raw message