< prev index next >

test/jdk/java/util/concurrent/tck/StampedLockTest.java

Print this page
8234131: Miscellaneous changes imported from jsr166 CVS 2020-12
Reviewed-by: martin

@@ -368,11 +368,11 @@
     /**
      * interruptible operations throw InterruptedException when write locked and interrupted
      */
     public void testInterruptibleOperationsThrowInterruptedExceptionWriteLockedInterrupted() {
         final StampedLock lock = new StampedLock();
-        long s = lock.writeLock();
+        long stamp = lock.writeLock();
 
         Action[] interruptibleLockBlockingActions = {
             () -> lock.writeLockInterruptibly(),
             () -> lock.tryWriteLock(Long.MAX_VALUE, DAYS),
             () -> lock.readLockInterruptibly(),

@@ -383,28 +383,32 @@
             () -> lock.asReadLock().tryLock(Long.MAX_VALUE, DAYS),
         };
         shuffle(interruptibleLockBlockingActions);
 
         assertThrowInterruptedExceptionWhenInterrupted(interruptibleLockBlockingActions);
+
+        releaseWriteLock(lock, stamp);
     }
 
     /**
      * interruptible operations throw InterruptedException when read locked and interrupted
      */
     public void testInterruptibleOperationsThrowInterruptedExceptionReadLockedInterrupted() {
         final StampedLock lock = new StampedLock();
-        long s = lock.readLock();
+        long stamp = lock.readLock();
 
         Action[] interruptibleLockBlockingActions = {
             () -> lock.writeLockInterruptibly(),
             () -> lock.tryWriteLock(Long.MAX_VALUE, DAYS),
             () -> lock.asWriteLock().lockInterruptibly(),
             () -> lock.asWriteLock().tryLock(Long.MAX_VALUE, DAYS),
         };
         shuffle(interruptibleLockBlockingActions);
 
         assertThrowInterruptedExceptionWhenInterrupted(interruptibleLockBlockingActions);
+
+        releaseReadLock(lock, stamp);
     }
 
     /**
      * Non-interruptible operations ignore and preserve interrupt status
      */

@@ -724,10 +728,11 @@
         long s = lock.writeLock();
         assertTrue(lock.toString().contains("Write-locked"));
         lock.unlockWrite(s);
         s = lock.readLock();
         assertTrue(lock.toString().contains("Read-locks"));
+        releaseReadLock(lock, s);
     }
 
     /**
      * tryOptimisticRead succeeds and validates if unlocked, fails if
      * exclusively locked
< prev index next >