You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by my...@apache.org on 2012/03/23 23:25:58 UTC
svn commit: r1304632 - in /db/derby/code/branches/10.6: ./
java/engine/org/apache/derby/catalog/ java/engine/org/apache/derby/impl/jdbc/
java/testing/org/apache/derbyTesting/functionTests/tests/tools/
Author: myrnavl
Date: Fri Mar 23 22:25:57 2012
New Revision: 1304632
URL: http://svn.apache.org/viewvc?rev=1304632&view=rev
Log:
DERBY-4443; Wrap rollback in exception handlers in try-catch
Merged revision 1096991 from trunk.
Patch was contributed by Houx Zhang (houxzhang at gmail dot com)
Added:
db/derby/code/branches/10.6/java/testing/org/apache/derbyTesting/functionTests/tests/tools/RollBackWrappingWhenFailOnImportTest.java
- copied unchanged from r1096991, db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/RollBackWrappingWhenFailOnImportTest.java
Modified:
db/derby/code/branches/10.6/ (props changed)
db/derby/code/branches/10.6/java/engine/org/apache/derby/catalog/SystemProcedures.java
db/derby/code/branches/10.6/java/engine/org/apache/derby/impl/jdbc/EmbedSQLException.java
db/derby/code/branches/10.6/java/testing/org/apache/derbyTesting/functionTests/tests/tools/_Suite.java
Propchange: db/derby/code/branches/10.6/
------------------------------------------------------------------------------
Merged /db/derby/code/trunk:r1096991
Modified: db/derby/code/branches/10.6/java/engine/org/apache/derby/catalog/SystemProcedures.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.6/java/engine/org/apache/derby/catalog/SystemProcedures.java?rev=1304632&r1=1304631&r2=1304632&view=diff
==============================================================================
--- db/derby/code/branches/10.6/java/engine/org/apache/derby/catalog/SystemProcedures.java (original)
+++ db/derby/code/branches/10.6/java/engine/org/apache/derby/catalog/SystemProcedures.java Fri Mar 23 22:25:57 2012
@@ -1466,14 +1466,25 @@ public class SystemProcedures {
replace, false);
}catch(SQLException se)
{
- //issue a rollback on any errors
- conn.rollback();
- throw se;
+ rollBackAndThrowSQLException(conn, se);
}
//import finished successfull, commit it.
conn.commit();
}
-
+
+ /**
+ * issue a rollback when SQLException se occurs. If SQLException ouccurs when rollback,
+ * the new SQLException will be added into the chain of se.
+ */
+ private static void rollBackAndThrowSQLException(Connection conn,
+ SQLException se) throws SQLException {
+ try {
+ conn.rollback();
+ } catch (SQLException e) {
+ se.setNextException(e);
+ }
+ throw se;
+ }
/**
* Import data from a given file to a table. Data for large object
@@ -1507,9 +1518,7 @@ public class SystemProcedures {
);
}catch(SQLException se)
{
- //issue a rollback on any errors
- conn.rollback();
- throw se;
+ rollBackAndThrowSQLException(conn, se);
}
//import finished successfull, commit it.
conn.commit();
@@ -1550,9 +1559,7 @@ public class SystemProcedures {
codeset, replace, false);
}catch(SQLException se)
{
- //issue a rollback on any errors
- conn.rollback();
- throw se;
+ rollBackAndThrowSQLException(conn, se);
}
//import finished successfull, commit it.
@@ -1598,9 +1605,7 @@ public class SystemProcedures {
codeset, replace, true);
}catch(SQLException se)
{
- //issue a rollback on any errors
- conn.rollback();
- throw se;
+ rollBackAndThrowSQLException(conn, se);
}
//import finished successfull, commit it.
Modified: db/derby/code/branches/10.6/java/engine/org/apache/derby/impl/jdbc/EmbedSQLException.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.6/java/engine/org/apache/derby/impl/jdbc/EmbedSQLException.java?rev=1304632&r1=1304631&r2=1304632&view=diff
==============================================================================
--- db/derby/code/branches/10.6/java/engine/org/apache/derby/impl/jdbc/EmbedSQLException.java (original)
+++ db/derby/code/branches/10.6/java/engine/org/apache/derby/impl/jdbc/EmbedSQLException.java Fri Mar 23 22:25:57 2012
@@ -104,6 +104,10 @@ public class EmbedSQLException extends S
return csqle;
}
public boolean isSimpleWrapper() {
+ if (getNextException() != null) {
+ return false;
+ }
+
return simpleWrapper;
}
}
Modified: db/derby/code/branches/10.6/java/testing/org/apache/derbyTesting/functionTests/tests/tools/_Suite.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.6/java/testing/org/apache/derbyTesting/functionTests/tests/tools/_Suite.java?rev=1304632&r1=1304631&r2=1304632&view=diff
==============================================================================
--- db/derby/code/branches/10.6/java/testing/org/apache/derbyTesting/functionTests/tests/tools/_Suite.java (original)
+++ db/derby/code/branches/10.6/java/testing/org/apache/derbyTesting/functionTests/tests/tools/_Suite.java Fri Mar 23 22:25:57 2012
@@ -55,6 +55,7 @@ public class _Suite extends BaseTestCase
suite.addTest(SysinfoCPCheckTest.suite());
suite.addTest(SysinfoLocaleTest.suite());
suite.addTest(IjSecurityManagerTest.suite());
+ suite.addTest(RollBackWrappingWhenFailOnImportTest.suite());
// SysinfoAPITest currently fails when run against jars, so is
// disabled. Only the first jar file on the classpath properly