jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From un...@apache.org
Subject svn commit: r1625281 - /jackrabbit/branches/2.8/jackrabbit-data/src/main/java/org/apache/jackrabbit/core/util/db/ConnectionHelper.java
Date Tue, 16 Sep 2014 13:44:19 GMT
Author: unico
Date: Tue Sep 16 13:44:19 2014
New Revision: 1625281

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

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

Modified: jackrabbit/branches/2.8/jackrabbit-data/src/main/java/org/apache/jackrabbit/core/util/db/ConnectionHelper.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.8/jackrabbit-data/src/main/java/org/apache/jackrabbit/core/util/db/ConnectionHelper.java?rev=1625281&r1=1625280&r2=1625281&view=diff
==============================================================================
--- jackrabbit/branches/2.8/jackrabbit-data/src/main/java/org/apache/jackrabbit/core/util/db/ConnectionHelper.java
(original)
+++ jackrabbit/branches/2.8/jackrabbit-data/src/main/java/org/apache/jackrabbit/core/util/db/ConnectionHelper.java
Tue Sep 16 13:44:19 2014
@@ -28,8 +28,6 @@ import java.util.Map;
 
 import javax.sql.DataSource;
 
-import org.apache.jackrabbit.core.util.db.Oracle10R1ConnectionHelper;
-import org.apache.jackrabbit.core.util.db.ResultSetWrapper;
 import org.apache.jackrabbit.data.core.TransactionContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -514,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;
     }
 
@@ -564,6 +547,9 @@ public class ConnectionHelper {
                     }
                     log.error("Failed to execute SQL (stacktrace on DEBUG log level): " +
lastException);
                     log.debug("Failed to execute SQL", lastException);
+                    if (!resetParamResources()) {
+                        break; // don't try again if streams cannot be reset
+                    }
                     failures++;
                     if (blockOnConnectionLoss || failures <= RETRIES) { // if we're going
to try again
                         try {
@@ -596,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