You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by re...@apache.org on 2014/11/28 14:51:36 UTC
svn commit: r1642299 -
/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentStore.java
Author: reschke
Date: Fri Nov 28 13:51:35 2014
New Revision: 1642299
URL: http://svn.apache.org/r1642299
Log:
OAK-1941 - do not rely on connection.close rolling back the transaction
Modified:
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentStore.java
Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentStore.java?rev=1642299&r1=1642298&r2=1642299&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentStore.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentStore.java Fri Nov 28 13:51:35 2014
@@ -685,6 +685,7 @@ public class RDBDocumentStore implements
connection.commit();
} catch (SQLException ex) {
success = false;
+ rollbackConnection(connection);
} finally {
closeConnection(connection);
}
@@ -839,7 +840,7 @@ public class RDBDocumentStore implements
connection.commit();
} catch (SQLException ex) {
continueIfStringOverflow(ex);
- connection.rollback();
+ rollbackConnection(connection);
success = false;
}
}
@@ -852,13 +853,7 @@ public class RDBDocumentStore implements
}
return success;
} catch (SQLException ex) {
- try {
- if (connection != null) {
- connection.rollback();
- }
- } catch (SQLException e) {
- // TODO
- }
+ rollbackConnection(connection);
throw new DocumentStoreException(ex);
} finally {
closeConnection(connection);
@@ -919,13 +914,7 @@ public class RDBDocumentStore implements
connection.commit();
} catch (SQLException ex) {
LOG.debug("insert of " + ids + " failed", ex);
- try {
- if (connection != null) {
- connection.rollback();
- }
- } catch (SQLException e) {
- // TODO
- }
+ rollbackConnection(connection);
throw new DocumentStoreException(ex);
} finally {
closeConnection(connection);
@@ -1011,7 +1000,7 @@ public class RDBDocumentStore implements
// DB2 throws an SQLException for invalid keys; handle this more
// gracefully
if ("22001".equals(ex.getSQLState())) {
- connection.rollback();
+ rollbackConnection(connection);
return null;
} else {
throw (ex);
@@ -1406,6 +1395,16 @@ public class RDBDocumentStore implements
return c;
}
+ private void rollbackConnection(Connection c) {
+ if (c != null) {
+ try {
+ c.rollback();
+ } catch (SQLException ex) {
+ // log me
+ }
+ }
+ }
+
private void closeConnection(Connection c) {
if (c != null) {
try {