[
https://issues.apache.org/jira/browse/NET-73?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13196804#comment-13196804
]
muralidhar polavarapu commented on NET-73:
------------------------------------------
I am facing same issue with commons-net-3.0.1 jar. TelentInputStream.read hangs
and thorows SocketTimeoutException
Using ERS on linux machine.
Stack trace:
java.net.SocketTimeoutException: Read timed out
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(SocketInputStream.java:129)
at java.io.BufferedInputStream.read1(BufferedInputStream.java:256)
at java.io.BufferedInputStream.read(BufferedInputStream.java:317)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
at java.io.BufferedInputStream.read(BufferedInputStream.java:237)
at
org.apache.commons.net.telnet.TelnetInputStream.__read(TelnetInputStream.java:136)
at
org.apache.commons.net.telnet.TelnetInputStream.run(TelnetInputStream.java:591)
at java.lang.Thread.run(Thread.java:619)
> [net][PATCH] TelnetInputStream.read hangs when socket data ends in a command
> sequence
> -------------------------------------------------------------------------------------
>
> Key: NET-73
> URL: https://issues.apache.org/jira/browse/NET-73
> Project: Commons Net
> Issue Type: Bug
> Environment: Operating System: other
> Platform: All
> Reporter: Rob Hasselbaum
> Attachments: cmd-seq-hang.patch
>
>
> Background: If one calls TelnetInputStream.read() in single-threaded mode (no
> reader thread) and there is no data immediately available, the call blocks on
> a socket read. When data starts to arrive, the stream adds all the available
> bytes to its internal queue before returning the first one to the caller. To
> do this, it calls __read() in a loop for as long as there are bytes
> available.
> The __read() method returns the first byte of "user data" from the socket. If
> __read() encounters a Telnet command sequence (IAC, WILL, WONT, DO, DONT,
> etc.), it handles the negotiation transparently and then returns the first
> byte of user data.
> In most cases, this works fine, but a problem arises if a chunk of data from
> the remote host ends in a Telnet command sequence. When that happens, the
> TelnetInputStream.read() method hangs, even though it may have already
> acquired some user data. This is because it calls __read() in a loop as long
> as super.available() returns true. But if the remaining data from the socket
> consists entirely of Telnet commands, __read() will process those AND THEN
> BLOCK waiting for user data.
> Just checking super.available() is not sufficient. We should continue the
> loop
> only if there are bytes of USER DATA still available from the socket. Not
> doing this can cause the client to wait indefinitely.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira