jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From un...@apache.org
Subject svn commit: r1625284 - /jackrabbit/branches/2.6/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/ConnectionHelper.java
Date Tue, 16 Sep 2014 13:49:07 GMT
Author: unico
Date: Tue Sep 16 13:49:07 2014
New Revision: 1625284

URL: http://svn.apache.org/r1625284
Log:
JCR-3809 don't swallow SQLException when binary streams can't be reset after sql execution
failed

Modified:
    jackrabbit/branches/2.6/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/ConnectionHelper.java

Modified: jackrabbit/branches/2.6/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/ConnectionHelper.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.6/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/ConnectionHelper.java?rev=1625284&r1=1625283&r2=1625284&view=diff
==============================================================================
--- jackrabbit/branches/2.6/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/ConnectionHelper.java
(original)
+++ jackrabbit/branches/2.6/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/util/db/ConnectionHelper.java
Tue Sep 16 13:49:07 2014
@@ -512,22 +512,7 @@ public class ConnectionHelper {
                 stmt.setObject(i + 1, p);
             }
         }
-        try {
-        	stmt.execute();
-        } catch (SQLException e) {
-        	//Reset Stream for retry ...
-            for (int i = 0; params != null && i < params.length; i++) {
-                Object p = params[i];
-                if (p instanceof StreamWrapper) {
-                    StreamWrapper wrapper = (StreamWrapper) p;
-                    if(!wrapper.resetStream()) {
-                    	wrapper.cleanupResources();
-                    	throw new RuntimeException("Unable to reset the Stream.");
-                    }
-                }
-            }
-        	throw e;
-        }
+        stmt.execute();
         return stmt;
     }
 
@@ -563,6 +548,9 @@ public class ConnectionHelper {
                     log.error("Failed to execute SQL (stacktrace on DEBUG log level): " +
lastException);
                     log.debug("Failed to execute SQL", lastException);
                     failures++;
+                    if (!resetParamResources()) {
+                        break;
+                    }
                     if (blockOnConnectionLoss || failures <= RETRIES) { // if we're going
to try again
                         try {
                             Thread.sleep(SLEEP_BETWEEN_RETRIES_MS);
@@ -594,5 +582,19 @@ public class ConnectionHelper {
 		        }
 		    }
 		}
+
+        protected boolean resetParamResources() {
+            for (int i = 0; params != null && i < params.length; i++) {
+                Object p = params[i];
+                if (p instanceof StreamWrapper) {
+                    StreamWrapper wrapper = (StreamWrapper) p;
+                    if(!wrapper.resetStream()) {
+                        wrapper.cleanupResources();
+                        return false;
+                    }
+                }
+            }
+            return true;
+        }
     }
 }



Mime
View raw message