Uploaded image for project: 'JGroups'
  1. JGroups
  2. JGRP-1239

Spurious warning "unblocking after xxx ms" from FLUSH.blockMessageDuringFlush()

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Minor Minor
    • 2.10.1, 2.11
    • 2.10
    • None
    • Low

      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);
      

              vblagoje Vladimir Blagojevic (Inactive)
              sirianni_jira Eric Sirianni (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved: