You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Rob Hasselbaum <rh...@bez.com> on 2006/02/16 17:44:35 UTC

[Net] TelnetInputStream.read sometimes hangs if reader thread is disabled

Hi,

I'm trying to use TelnetClient with the reader thread disabled because I
don't want socket timeouts to fire during planned periods of inactivity
(bug #31122).

But when the thread is disabled, I'm finding that TelnetInputStream.read
hangs forever sometimes while I'm trying to read output from the server.
The problem appears to be the first while loop in __processChar, which
looks like this:

synchronized (__queue)
{
  while (__bytesAvailable >= __queue.length - 1)
  {
    if(__threaded)
    {
      __queue.notify();
      try
      {
        __queue.wait();
      }
      catch (InterruptedException e)
      {
        throw e;
      }
    }
  ...
}

If you get into this loop and the threaded flag is false, I think you
are stuck forever. That's what's happening in my case. If I suspend the
thread, I can see that (__bytesAvailable) is 2048 and (__queue.length -
1) is also 2048. It's an infinite loop.

Am I missing something or is this a bug? If it's a bug, I'm surprised no
one has run into it before now. I couldn't find anything open about it.

Thanks,
Rob H.

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org