db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From myrn...@apache.org
Subject svn commit: r1304636 - in /db/derby/code/branches/10.5: ./ java/ java/engine/org/apache/derby/catalog/ java/engine/org/apache/derby/impl/jdbc/ java/testing/org/apache/derbyTesting/functionTests/tests/tools/
Date Fri, 23 Mar 2012 22:36:13 GMT
Author: myrnavl
Date: Fri Mar 23 22:36:13 2012
New Revision: 1304636

URL: http://svn.apache.org/viewvc?rev=1304636&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.5/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.5/   (props changed)
    db/derby/code/branches/10.5/java/   (props changed)
    db/derby/code/branches/10.5/java/engine/org/apache/derby/catalog/SystemProcedures.java
    db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/jdbc/EmbedSQLException.java
    db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/tools/_Suite.java

Propchange: db/derby/code/branches/10.5/
------------------------------------------------------------------------------
  Merged /db/derby/code/trunk:r1096991

Propchange: db/derby/code/branches/10.5/java/
------------------------------------------------------------------------------
  Merged /db/derby/code/trunk/java:r1096991

Modified: db/derby/code/branches/10.5/java/engine/org/apache/derby/catalog/SystemProcedures.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.5/java/engine/org/apache/derby/catalog/SystemProcedures.java?rev=1304636&r1=1304635&r2=1304636&view=diff
==============================================================================
--- db/derby/code/branches/10.5/java/engine/org/apache/derby/catalog/SystemProcedures.java
(original)
+++ db/derby/code/branches/10.5/java/engine/org/apache/derby/catalog/SystemProcedures.java
Fri Mar 23 22:36:13 2012
@@ -1455,14 +1455,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 
@@ -1496,9 +1507,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();
@@ -1539,9 +1548,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.
@@ -1587,9 +1594,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.5/java/engine/org/apache/derby/impl/jdbc/EmbedSQLException.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/jdbc/EmbedSQLException.java?rev=1304636&r1=1304635&r2=1304636&view=diff
==============================================================================
--- db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/jdbc/EmbedSQLException.java
(original)
+++ db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/jdbc/EmbedSQLException.java
Fri Mar 23 22:36:13 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.5/java/testing/org/apache/derbyTesting/functionTests/tests/tools/_Suite.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/tools/_Suite.java?rev=1304636&r1=1304635&r2=1304636&view=diff
==============================================================================
--- db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/tools/_Suite.java
(original)
+++ db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/tools/_Suite.java
Fri Mar 23 22:36:13 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



Mime
View raw message