Search in sources :

Example 1 with DefaultISMLocking

use of org.apache.jackrabbit.core.state.DefaultISMLocking 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];
    }
}
Also used : ISMLocking(org.apache.jackrabbit.core.state.ISMLocking) DefaultISMLocking(org.apache.jackrabbit.core.state.DefaultISMLocking) ReadLock(org.apache.jackrabbit.core.state.ISMLocking.ReadLock) WriteLock(org.apache.jackrabbit.core.state.ISMLocking.WriteLock) DefaultISMLocking(org.apache.jackrabbit.core.state.DefaultISMLocking)

Aggregations

DefaultISMLocking (org.apache.jackrabbit.core.state.DefaultISMLocking)1 ISMLocking (org.apache.jackrabbit.core.state.ISMLocking)1 ReadLock (org.apache.jackrabbit.core.state.ISMLocking.ReadLock)1 WriteLock (org.apache.jackrabbit.core.state.ISMLocking.WriteLock)1