boolean (CountDownLatch latch, AtomicReference<? super String> error, String message, boolean expected) { if (expected == getApplication().isReadAccessAllowed()) return true; StringBuilder sb = new StringBuilder(expected ? "No expected" : "Unexpected"); error.set(sb.append(" read action ").append(message).append(" acquiring a read lock").toString()); latch.countDown(); // interrupt with the specified error return false; }