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

SocketAppender maysilently drop events in quick succession

    XMLWordPrintable

Details

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Major Major
    • None
    • 1.0.13
    • logback-core
    • None

    Description

      There is a race condition in AbstractSocketAppender – if the queue is "full" then this line will silently drop the event:

      queue.offer(event);
      

      To avoid dropped events, the code should be using "add" instead of "offer" to ensure that the caller blocks if the queue is full.

      This is very easy to reproduce with the default queue size of zero.

      The javadoc for AbstractSocketAppender seems to contract itself on this matter, it claims:

      • "Using a non-zero queue length can improve performance by eliminating delays caused by transient network delays."
      • "If the queue is full when the append(Object) method is called, the event is summarily and silently dropped."

      If events are dropped when the queue is full, then there aren't any "delays" to worry about, only "dropped" events. If dropping events is the intended behavior, I think append() should check the return value of offer() and call addWarn() to notify the user that messages are being dropped (at least for the first such drop). Then the user will know that the queue size must be increased.

      Attachments

        Activity

          People

            logback-dev Logback dev list
            brettv Brett Vasconcellos
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: