jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From un...@apache.org
Subject svn commit: r1625542 - in /jackrabbit/branches/2.8: jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/AppendRecord.java jackrabbit-data/src/main/java/org/apache/jackrabbit/core/util/db/ConnectionHelper.java
Date Wed, 17 Sep 2014 12:11:35 GMT
Author: unico
Date: Wed Sep 17 12:11:35 2014
New Revision: 1625542

URL: http://svn.apache.org/r1625542
Log:
JCR-3811 
- Allow retrying of failed journal entry database inserts
- Fix bug in ConnectionHelper where resources were not cleaned up when a SQL call would fail
in batch mode

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

Modified: jackrabbit/branches/2.8/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/AppendRecord.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.8/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/AppendRecord.java?rev=1625542&r1=1625541&r2=1625542&view=diff
==============================================================================
--- jackrabbit/branches/2.8/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/AppendRecord.java
(original)
+++ jackrabbit/branches/2.8/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/AppendRecord.java
Wed Sep 17 12:11:35 2014
@@ -16,6 +16,7 @@
  */
 package org.apache.jackrabbit.core.journal;
 
+import org.apache.jackrabbit.core.data.db.TempFileInputStream;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -23,7 +24,6 @@ import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.DataOutputStream;
 import java.io.File;
-import java.io.FileInputStream;
 import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.io.IOException;
@@ -298,7 +298,7 @@ public class AppendRecord extends Abstra
     private InputStream openInput() throws JournalException {
         if (file != null) {
             try {
-                return new FileInputStream(file);
+                return new TempFileInputStream(file, false);
             } catch (IOException e) {
                 String msg = "Unable to open file input on: " + file.getPath();
                 throw new JournalException(msg, e);

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=1625542&r1=1625541&r2=1625542&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
Wed Sep 17 12:11:35 2014
@@ -531,38 +531,39 @@ public class ConnectionHelper {
     	}
     	
         public final T doTry() throws SQLException {
-            if (inBatchMode()) {
-                return call();
-            } else {
-                boolean sleepInterrupted = false;
-                int failures = 0;
-                SQLException lastException = null;
-                while (!sleepInterrupted && (blockOnConnectionLoss || failures <=
RETRIES)) {
-                    try {
-                    	T object = call(); 
-                        cleanupParamResources();
-                        return object;
-                    } catch (SQLException e) {
-                        lastException = e;
-                    }
-                    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 {
+                if (inBatchMode()) {
+                    return call();
+                } else {
+                    boolean sleepInterrupted = false;
+                    int failures = 0;
+                    SQLException lastException = null;
+                    while (!sleepInterrupted && (blockOnConnectionLoss || failures
<= RETRIES)) {
                         try {
-                            Thread.sleep(SLEEP_BETWEEN_RETRIES_MS);
-                        } catch (InterruptedException e1) {
-                            Thread.currentThread().interrupt();
-                            sleepInterrupted = true;
-                            log.error("Interrupted: canceling retry");
+                            return call();
+                        } catch (SQLException e) {
+                            lastException = e;
+                        }
+                        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 {
+                                Thread.sleep(SLEEP_BETWEEN_RETRIES_MS);
+                            } catch (InterruptedException e1) {
+                                Thread.currentThread().interrupt();
+                                sleepInterrupted = true;
+                                log.error("Interrupted: canceling retry");
+                            }
                         }
                     }
+                    throw lastException;
                 }
+            } finally {
                 cleanupParamResources();
-                throw lastException;
             }
         }
 
@@ -589,7 +590,6 @@ public class ConnectionHelper {
                 if (p instanceof StreamWrapper) {
                     StreamWrapper wrapper = (StreamWrapper) p;
                     if(!wrapper.resetStream()) {
-                        wrapper.cleanupResources();
                         return false;
                     }
                 }



Mime
View raw message