use of org.apache.jackrabbit.core.state.ISMLocking.ReadLock in project jackrabbit by apache.
the class AbstractISMLockingTest method testReadBlocksWrite.
/**
* Checks the following requirement: <p/> <i>While a read lock is held for a given item with id
* <code>I</code> an implementation must ensure that no write lock is issued for a change log that
* contains a reference to an item with id <code>I</code>. </i>
*
* @throws InterruptedException on interruption; this will err the test
*/
public void testReadBlocksWrite() throws InterruptedException {
ReadLock rLock = locking.acquireReadLock(state.getId());
for (ChangeLog changeLog : logs) {
verifyBlocked(startWriterThread(locking, changeLog));
}
rLock.release();
}
use of org.apache.jackrabbit.core.state.ISMLocking.ReadLock in project jackrabbit by apache.
the class AbstractISMLockingTest method testDowngrade.
/**
* Checks if a downgraded write lock allows other threads to read again.
*
* @throws InterruptedException on interruption; this will err the test
*/
public void testDowngrade() throws InterruptedException {
for (ChangeLog changeLog : logs) {
WriteLock wLock = locking.acquireWriteLock(changeLog);
verifyBlocked(startReaderThread(locking, state.getId()));
ReadLock rLock = wLock.downgrade();
verifyNotBlocked(startReaderThread(locking, state.getId()));
rLock.release();
}
}
use of org.apache.jackrabbit.core.state.ISMLocking.ReadLock in project jackrabbit by apache.
the class DefaultISMLockingDeadlockTest method test.
public void test() throws InterruptedException {
final ISMLocking lock = new DefaultISMLocking();
WriteLock w1 = lock.acquireWriteLock(null);
ReadLock r1 = w1.downgrade();
final InterruptedException[] ex = new InterruptedException[1];
Thread thread = new Thread() {
public void run() {
try {
lock.acquireWriteLock(null).release();
} catch (InterruptedException e) {
ex[0] = e;
}
}
};
thread.start();
Thread.sleep(100);
lock.acquireReadLock(null).release();
r1.release();
thread.join();
if (ex[0] != null) {
throw ex[0];
}
}
Aggregations