Uploaded image for project: 'logback'
  1. logback
  2. LOGBACK-1382

AsyncAppender#putUninterruptibly may loop forever

    Details

    • Type: Task
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 1.2.3
    • Fix Version/s: None
    • Component/s: logback-core
    • Labels:
      None
    • Environment:

       

       

       

      Description

      The code in AsyncAppenderBase#putUninterruptibly is suspicious, if InterruptedException is raised in blockingQueue.put(...), the interrupted flag is set to true but as there is a while(true) around the current Thread will not be interrupted, loop forever and the code in the finally block may never occur.

       

      private void putUninterruptibly(E eventObject) {
          boolean interrupted = false;
          try {
              while (true) {
                  try {
                      blockingQueue.put(eventObject);
                      break;
                  } catch (InterruptedException e) {
                      interrupted = true;
                  }
              }
          } finally {
              if (interrupted) {
                  Thread.currentThread().interrupt();
              }
          }
      }
      

      What's the purpose of this infinite loop?

      I suspect the intent was to write while(!interrupted&&!pushed) instead of while(true).

      To me, the blockingQueue.put is a blocking operation, the current thread will wait until it can push the event in the queue. Attempting multiple retries seems useless and dangerous to me. At least the number of retries should be bounded.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                logback-dev Logback dev list
                Reporter:
                gquintana Gérald Quintana
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated: