db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From krist...@apache.org
Subject svn commit: r1333360 - /db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/CleanDatabaseTestSetup.java
Date Thu, 03 May 2012 08:49:31 GMT
Author: kristwaa
Date: Thu May  3 08:49:31 2012
New Revision: 1333360

URL: http://svn.apache.org/viewvc?rev=1333360&view=rev
Log:
DERBY-5734: End transaction if CleanDatabaseTestSetup.decorateSQL fails

Make sure the transaction is ended even if decorateSQL, which can be
overridden to perform custom setup tasks, fails.
This patch also nulls out the reference to the default connection
(clearConnection() must be paired with getConnection())

Patch file: derby-5734-1b-end_transaction.diff

Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/CleanDatabaseTestSetup.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/CleanDatabaseTestSetup.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/CleanDatabaseTestSetup.java?rev=1333360&r1=1333359&r2=1333360&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/CleanDatabaseTestSetup.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/CleanDatabaseTestSetup.java
Thu May  3 08:49:31 2012
@@ -109,11 +109,23 @@ public class CleanDatabaseTestSetup exte
         CleanDatabaseTestSetup.cleanDatabase(conn, true);  
         
         Statement s = conn.createStatement();
-        decorateSQL(s);
-
-        s.close();
-        conn.commit();
-        conn.close();
+        try {
+            decorateSQL(s);
+            s.close();
+            conn.commit();
+        } finally {
+            // Make sure we release any locks held by the connection at this
+            // point. Not doing so may cause subsequent tests to fail.
+            try {
+                clearConnection();
+            } catch (SQLException sqle) {
+                // Ignore, but print details in debug mode.
+                if (getTestConfiguration().isVerbose()) {
+                    println("clearing connection failed: " + sqle.getMessage());
+                    sqle.printStackTrace(System.err);
+                }
+            }
+        }
     }
     
     /**



Mime
View raw message