JavaDoc from java.util.concurrent.locks.Condition.await(...) indicates that FALSE is returned if a timeout occurred.
/** * ... * @return {@code false} if the waiting time detectably elapsed * before return from the method, else {@code true} */ boolean await(long time, TimeUnit unit) throws InterruptedException;
However, the JGroups code below is acting as if TRUE is returned if a timeout occurred.
private void blockMessageDuringFlush() { boolean shouldSuspendByItself = false; blockMutex.lock(); try { while (isBlockingFlushDown) { if (log.isDebugEnabled()) log.debug(localAddress + ": blocking for " + (timeout <= 0 ? "ever" : timeout + "ms")); shouldSuspendByItself = notBlockedDown.await(timeout, TimeUnit.MILLISECONDS); } if (shouldSuspendByItself) { isBlockingFlushDown = false; log.warn(localAddress + ": unblocking after " + timeout + "ms"); flush_promise.setResult(Boolean.TRUE); notBlockedDown.signalAll(); } } catch (InterruptedException e) { Thread.currentThread().interrupt(); } finally { blockMutex.unlock(); } }
This causes spurious WARNING level messages to be logged by JGroups when in fact no timeout occurred.
The fix is simple:
< shouldSuspendByItself = notBlockedDown.await(timeout, TimeUnit.MILLISECONDS); -- > shouldSuspendByItself = !notBlockedDown.await(timeout, TimeUnit.MILLISECONDS);