db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mi...@apache.org
Subject svn commit: r1071365 - in /db/derby/code/branches/10.5/java: engine/org/apache/derby/impl/services/locks/ testing/org/apache/derbyTesting/functionTests/tests/engine/ testing/org/apache/derbyTesting/junit/
Date Wed, 16 Feb 2011 19:20:03 GMT
Author: mikem
Date: Wed Feb 16 19:20:03 2011
New Revision: 1071365

URL: http://svn.apache.org/viewvc?rev=1071365&view=rev
Log:
DERBY-4711 Hung thread after another thread is interrupted.

backported change #1040551 from 10.6 branch to 10.5 branch.

Merged fix from trunk (revisions 957902, 958257, 958264, and 958508).


Added:
    db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/engine/LockInterruptTest.java
      - copied unchanged from r1040551, db/derby/code/branches/10.6/java/testing/org/apache/derbyTesting/functionTests/tests/engine/LockInterruptTest.java
Modified:
    db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/services/locks/ConcurrentLockSet.java
    db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/services/locks/LockSet.java
    db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/engine/_Suite.java
    db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/junit/BaseTestCase.java

Modified: db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/services/locks/ConcurrentLockSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/services/locks/ConcurrentLockSet.java?rev=1071365&r1=1071364&r2=1071365&view=diff
==============================================================================
--- db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/services/locks/ConcurrentLockSet.java
(original)
+++ db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/services/locks/ConcurrentLockSet.java
Wed Feb 16 19:20:03 2011
@@ -460,12 +460,22 @@ final class ConcurrentLockSet implements
 
 forever:	for (;;) {
 
-                byte wakeupReason = waitingLock.waitForGrant(actualTimeout);
-                
+                byte wakeupReason = 0;
                 ActiveLock nextWaitingLock = null;
                 Object[] deadlockData = null;
 
                 try {
+                    try {
+                        wakeupReason = waitingLock.waitForGrant(actualTimeout);
+                    } catch(StandardException e) {
+                        // DERBY-4711: If waitForGrant() fails, we need to
+                        // remove ourselves from the queue so that those
+                        // behind us in the queue don't get stuck waiting for
+                        // us.
+                        nextWaitingLock = control.getNextWaiter(waitingLock, true, this);
+                        throw e;
+                    }
+
                     boolean willQuitWait;
                     Enumeration timeoutLockTable = null;
                     long currentTime = 0;

Modified: db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/services/locks/LockSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/services/locks/LockSet.java?rev=1071365&r1=1071364&r2=1071365&view=diff
==============================================================================
--- db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/services/locks/LockSet.java
(original)
+++ db/derby/code/branches/10.5/java/engine/org/apache/derby/impl/services/locks/LockSet.java
Wed Feb 16 19:20:03 2011
@@ -273,12 +273,22 @@ final class LockSet implements LockTable
 
 forever:	for (;;) {
 
-                byte wakeupReason = waitingLock.waitForGrant(actualTimeout);
-                
+                byte wakeupReason = 0;
                 ActiveLock nextWaitingLock = null;
                 Object[] deadlockData = null;
 
                 try {
+                    try {
+                        wakeupReason = waitingLock.waitForGrant(actualTimeout);
+                    } catch(StandardException e) {
+                        // DERBY-4711: If waitForGrant() fails, we need to
+                        // remove ourselves from the queue so that those
+                        // behind us in the queue don't get stuck waiting for
+                        // us.
+                        nextWaitingLock = control.getNextWaiter(waitingLock, true, this);
+                        throw e;
+                    }
+
                     boolean willQuitWait;
                     Enumeration timeoutLockTable = null;
                     long currentTime = 0;

Modified: db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/engine/_Suite.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/engine/_Suite.java?rev=1071365&r1=1071364&r2=1071365&view=diff
==============================================================================
--- db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/engine/_Suite.java
(original)
+++ db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/engine/_Suite.java
Wed Feb 16 19:20:03 2011
@@ -47,6 +47,7 @@ public class _Suite extends BaseTestCase
         TestSuite suite = new TestSuite("engine");
 
         suite.addTest(ErrorStreamTest.suite());
+        suite.addTest(LockInterruptTest.suite());
         suite.addTest(ModuleLoadingTest.suite());
 
         return suite;

Modified: db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/junit/BaseTestCase.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/junit/BaseTestCase.java?rev=1071365&r1=1071364&r2=1071365&view=diff
==============================================================================
--- db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/junit/BaseTestCase.java
(original)
+++ db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/junit/BaseTestCase.java
Wed Feb 16 19:20:03 2011
@@ -621,15 +621,15 @@ public abstract class BaseTestCase
      * Fail; attaching an exception for more detail on cause.
      *
      * @param msg message explaining the failure
-     * @param e exception related to the cause
+     * @param t the cause of the failure
      *
      * @exception AssertionFailedError
      */
-    public static void fail(String msg, Exception e)
+    public static void fail(String msg, Throwable t)
             throws AssertionFailedError {
 
         AssertionFailedError ae = new AssertionFailedError(msg);
-        ae.initCause(e);
+        ae.initCause(t);
         throw ae;
     }
 } // End class BaseTestCase



Mime
View raw message