use of org.apache.jackrabbit.oak.segment.WriteOperationHandler.WriteOperation in project jackrabbit-oak by apache.
the class SegmentBufferWriterPoolTest method testFlushBlocks.
@Test
public void testFlushBlocks() throws ExecutionException, InterruptedException {
Future<RecordId> res = execute(new WriteOperation() {
@Nonnull
@CheckForNull
@Override
public RecordId execute(@Nonnull SegmentBufferWriter writer) {
try {
// This should deadlock as flush waits for this write
// operation to finish, which in this case contains the
// call to flush itself.
executors[1].submit(new Callable<Void>() {
@Override
public Void call() throws Exception {
pool.flush(store);
return null;
}
}).get(100, MILLISECONDS);
// No deadlock -> null indicates test failure
return null;
} catch (InterruptedException | ExecutionException ignore) {
// No deadlock -> null indicates test failure
return null;
} catch (TimeoutException ignore) {
// Deadlock -> rootId indicates test pass
return rootId;
}
}
}, 0);
assertEquals(rootId, res.get());
}
Aggregations