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

Telnet spyStream NullPointerException

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.0
    • Fix Version/s: 2.2
    • Component/s: None
    • Labels:
      None

      Description

      Calling stopSpyStream on TelnetClient sets spyStream to null without regard to whether _spyRead or _spyWrite are being invoked on another thread.

      Resulting NPE in _spyRead/_spy_Write is caught in TelnetInputStream.run() which goes on to close the stream.

      May be able to fix by taking local copy of spyStream (which ought also to be volatile) in both of _spyRead and _spyWrite. E.g. for _spyRead:

      void _spyRead(int ch)
      {
      OutputStream _spyStream = spyStream;

      if (_spyStream != null)
      {
      try
      {
      if (ch != '\r')
      {
      _spyStream.write(ch);
      if (ch == '\n')

      { _spyStream.write('\r'); }

      _spyStream.flush();
      }
      }
      catch (IOException e)

      { spyStream = null; }

      }
      }

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              jeremystone Jeremy Stone
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: