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

SocketNode constructor blocks due to ObjectInputStream creation

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 0.9.16
    • Fix Version/s: 1.1.0
    • Component/s: logback-classic
    • Labels:
      None
    • Environment:

      Using Logback 0.9.9, but problem is still present in trunk

      Description

      SocketNode implements Runnable, the implication being that a SocketNode can be run in its own thread like this:

      while (true) {
      // accept a client connection
      new Thread(new SocketNode(...)).start();
      }

      However the SocketNode creates an ObjectInputStream using the socket's input stream, which blocks waiting for the stream header - so the constructor does not return, the thread cannot start and the loop shown above cannot continue until data has been received from the client.

      Typically a client would connect and immediately send data, so this wouldn't be an issue, but if someone just telnets to the log server and doesn't send any data, the above loop will block and prevent other clients' log messages from being processed.

      It would be better if the ObjectInputStream was created in the run() method to avoid the constructor blocking.

        Attachments

          Activity

            People

            • Assignee:
              tony19 Tony Trinh
              Reporter:
              richardfearn Richard Fearn
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: