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 da...@apache.org on 2011/05/13 19:41:38 UTC

svn commit: r1102826 - in /db/derby/code/trunk/java: engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java testing/org/apache/derbyTesting/functionTests/tests/store/InterruptResilienceTest.java

Author: dag
Date: Fri May 13 17:41:38 2011
New Revision: 1102826

URL: http://svn.apache.org/viewvc?rev=1102826&view=rev
Log:
DERBY-5223 Thread's interrupted flag not always preserved after Derby returns from JDBC API call

Patch DERBY-5223b: This fix moves the initialization of the variable
"interruptedException" earlier in
GenericLanguageConnectionContext#initialize and adds a missing
reinitialization to resetFromPool as a precaution (if
interruptedException is still non-null the connection should have
throws 08000).

The patch also changes the InterruptResilienceTest so that JUnit
asserts in the worker threads will get propagated to the main test
thread on completion, so any future errors in these invariants do not
get overlooked.


Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/InterruptResilienceTest.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java?rev=1102826&r1=1102825&r2=1102826&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java Fri May 13 17:41:38 2011
@@ -377,6 +377,7 @@ public class GenericLanguageConnectionCo
 
     public void initialize() throws StandardException
     {
+        interruptedException = null;
         sessionUser = IdUtil.getUserAuthorizationId(userName);
         //
         //Creating the authorizer authorizes the connection.
@@ -397,9 +398,7 @@ public class GenericLanguageConnectionCo
             }
         }
 
-
         setDefaultSchema(initDefaultSchemaDescriptor());
-        interruptedException = null;
         referencedColumnMap = new WeakHashMap();
     }
 
@@ -808,6 +807,8 @@ public class GenericLanguageConnectionCo
     public void resetFromPool()
          throws StandardException
     {
+        interruptedException = null;
+
         // Reset IDENTITY_VAL_LOCAL
         identityNotNull = false;
 

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/InterruptResilienceTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/InterruptResilienceTest.java?rev=1102826&r1=1102825&r2=1102826&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/InterruptResilienceTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/InterruptResilienceTest.java Fri May 13 17:41:38 2011
@@ -369,7 +369,7 @@ public class InterruptResilienceTest ext
     static class WorkerThread extends Thread {
         private final boolean readertest;
         private final long noOps;
-        public Exception e; // if any seen
+        public Throwable e; // if any seen
         private Connection c;
 
         public WorkerThread(Connection c, boolean readertest, long noOps) {
@@ -432,7 +432,7 @@ public class InterruptResilienceTest ext
                                 retries++;
                                 continue;
                             } else {
-                                throw new Exception("expected 08000, saw" + e);
+                                fail("expected 08000", e);
                             }
                         }
 
@@ -459,7 +459,7 @@ public class InterruptResilienceTest ext
                                 retries++;
                                 continue;
                             } else {
-                                throw new Exception("expected 08000, saw" + e);
+                                fail("expected 08000", e);
                             }
                         }
 
@@ -476,7 +476,7 @@ public class InterruptResilienceTest ext
                     }
                 }
                 s.close();
-            } catch (Exception e) {
+            } catch (Throwable e) {
                 this.e = e;
             } finally {
                 try { c.close(); } catch (Exception e) {}