< prev index next >

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

Print this page
8234131: Miscellaneous changes imported from jsr166 CVS 2021-01
Reviewed-by: martin

*** 368,378 **** /** * interruptible operations throw InterruptedException when write locked and interrupted */ public void testInterruptibleOperationsThrowInterruptedExceptionWriteLockedInterrupted() { final StampedLock lock = new StampedLock(); ! long s = lock.writeLock(); Action[] interruptibleLockBlockingActions = { () -> lock.writeLockInterruptibly(), () -> lock.tryWriteLock(Long.MAX_VALUE, DAYS), () -> lock.readLockInterruptibly(), --- 368,378 ---- /** * interruptible operations throw InterruptedException when write locked and interrupted */ public void testInterruptibleOperationsThrowInterruptedExceptionWriteLockedInterrupted() { final StampedLock lock = new StampedLock(); ! long stamp = lock.writeLock(); Action[] interruptibleLockBlockingActions = { () -> lock.writeLockInterruptibly(), () -> lock.tryWriteLock(Long.MAX_VALUE, DAYS), () -> lock.readLockInterruptibly(),
*** 383,410 **** () -> lock.asReadLock().tryLock(Long.MAX_VALUE, DAYS), }; shuffle(interruptibleLockBlockingActions); assertThrowInterruptedExceptionWhenInterrupted(interruptibleLockBlockingActions); } /** * interruptible operations throw InterruptedException when read locked and interrupted */ public void testInterruptibleOperationsThrowInterruptedExceptionReadLockedInterrupted() { final StampedLock lock = new StampedLock(); ! long s = 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); } /** * Non-interruptible operations ignore and preserve interrupt status */ --- 383,414 ---- () -> 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 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,733 **** --- 728,738 ---- 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 >