Menu

#1 SocketReader.readGreeting makes wrong assumption

open
nobody
None
5
2010-10-16
2010-10-16
No

de.dermoba.srcp.common.SocketReader.readGreeting() differs from the normal read() method. For unknwon reasons (no comment) it does not read a line (i.e. does not read until LINEFEED is encountered). Instead it simply appends characters while the input stream has data ("ready()").

This works only if the greeting is returned from the server as a single "chunk" of data. There is no basis for this assumption, neither from the Java API nor from anything else. Event assuming that the data is sent over the network in one packet, there is no guarantee that the packet is delivered by the OS to the socket reader at once.

In my environment, this definitely does not work. I put a Thread.sleep(100) before the while loop for testing. This fixes the problem. But I don't see any reason why the greeting is not simply read as a line terminated by LF or CRLF.

The bug does not only spoil the greeting. It makes the SocketReader loose the synchronization with the server, because the response to the first command is the rest of the greeting.

Discussion


Log in to post a comment.