Uploaded image for project: 'Commons Net'
  1. Commons Net
  2. NET-466

Regression: TelnetInputStream#available() blocks

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: 3.1
    • Fix Version/s: 3.2
    • Component/s: Telnet
    • Labels:
      None

      Description

      When testing with Commons Net 3.1 for Eclipse https://bugs.eclipse.org/bugs/show_bug.cgi?id=194473 , I found that our telnet client blocks when the ReaderThread is running and waiting for new data. Investigation shows that our code blocks on TelnetInputStream#available().

      This regression is due to the code introduced for NET-437 "TelnetInputStream doesn't support non-blocking IO when reader thread is not enabled":

      TelnetInputStream#available() now calls super.available() which is declared as "synchronized" on BufferedInputStream in JDK 1.6.0_21 at least. But at the same time, the telnet ReaderThread has already the Monitor on BufferedInputStream and doesn't give it up while sitting in read0().

      This seems to be exactly the situation that the comment before TelnetInputStream#close() warns about:
      // Cannot be synchronized. Will cause deadlock if run() is blocked
      // in read because BufferedInputStream read() is synchronized.

      This is a severe issue since it violates the specification and use of available().

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                moberhuber Martin Oberhuber
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: