jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1173169 - /jackrabbit/branches/JCR-2272/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/pool/BundleDbPersistenceManager.java
Date Tue, 20 Sep 2011 14:39:13 GMT
Author: jukka
Date: Tue Sep 20 14:39:13 2011
New Revision: 1173169

URL: http://svn.apache.org/viewvc?rev=1173169&view=rev
Log:
JCR-2272: Errors during concurrent session import of nodes with same UUIDs

Use SQLState 23xxx instead of the Java 6 SQLIntegrityConstraintViolationException to check
for integrity issues

Modified:
    jackrabbit/branches/JCR-2272/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/pool/BundleDbPersistenceManager.java

Modified: jackrabbit/branches/JCR-2272/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/pool/BundleDbPersistenceManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/JCR-2272/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/pool/BundleDbPersistenceManager.java?rev=1173169&r1=1173168&r2=1173169&view=diff
==============================================================================
--- jackrabbit/branches/JCR-2272/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/pool/BundleDbPersistenceManager.java
(original)
+++ jackrabbit/branches/JCR-2272/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/persistence/pool/BundleDbPersistenceManager.java
Tue Sep 20 14:39:13 2011
@@ -24,7 +24,6 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.sql.ResultSet;
 import java.sql.SQLException;
-import java.sql.SQLIntegrityConstraintViolationException;
 import java.sql.Types;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -495,9 +494,9 @@ public class BundleDbPersistenceManager
                     DbUtility.logException("rollback failed", e2);
                 }
 
-                // if we got here due to a constraint violation and we are running in
-                // test mode, we really want to stop
-                assert !(e.getCause() instanceof SQLIntegrityConstraintViolationException);
+                // if we got here due to a constraint violation and we
+                // are running in test mode, we really want to stop
+                assert !isIntegrityConstraintViolation(e.getCause());
             }
             failures++;
             log.error("Failed to persist ChangeLog (stacktrace on DEBUG log level), blockOnConnectionLoss
= "
@@ -516,6 +515,15 @@ public class BundleDbPersistenceManager
         throw lastException;
     }
 
+    private boolean isIntegrityConstraintViolation(Throwable t) {
+        if (t instanceof SQLException) {
+            String state = ((SQLException) t).getSQLState();
+            return state != null && state.startsWith("23");
+        } else {
+            return false;
+        }
+    }
+
     /**
      * {@inheritDoc}
      */
@@ -1110,7 +1118,7 @@ public class BundleDbPersistenceManager
         } catch (Exception e) {
             String msg;
 
-            if (e instanceof SQLIntegrityConstraintViolationException) {
+            if (isIntegrityConstraintViolation(e)) {
                 // we should never get an integrity constraint violation here
                 // other PMs may not be able to detect this and end up with
                 // corrupted data



Mime
View raw message