Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #38954

Re: readLine() and newline problem

Newsgroups comp.lang.java.programmer
Date 2019-05-10 01:29 -0700
References <8beb1189-8953-4072-9b4b-0d54cf64eaa5@googlegroups.com> <qb37mg$oj8$1@dont-email.me>
Message-ID <e082e8d0-0d47-4728-a112-f0ab82d4eda1@googlegroups.com> (permalink)
Subject Re: readLine() and newline problem
From mike <mikaelpetterson@hotmail.com>

Show all headers | View raw


Den fredag 10 maj 2019 kl. 09:02:49 UTC+2 skrev Daniele Futtorovic:
> On 2019-05-10 08:16, mike wrote:
> > The problem here is that some devices add a newline after "]]>]]>" which is the message separator. And of course some devices don't since it is not required in the RFC6242.
> > 
> > So when there is no newline from device then the above method will hang. Then I thought it would be easy to create a unit test that recreates the problem. One with a hello message with message separator and newline and one with only message separator. But problem is that I get no exception in the test without the newline. Any ideas what I am missing or how I can re-create the issue?
> 
> In your test, an EOF takes the place of the otherwise expected EOL and
> makes it work.
> 
> As for the problem overall, in my view you definitely shouldn't be using
> readLine() here. You should be reading with read(char[]) and keep doing
> so until you encounter the separator.
> 
> -- 
> DF.

So how can I update test to simulate my error?

Yes I am also thinking of using read(char []). I think it is more appropriate. The only thing that will be a bit tricky is to find my separator char.I have to check if we have ] then another ] so there will be many ifs.

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

readLine() and newline problem mike <mikaelpetterson@hotmail.com> - 2019-05-09 23:16 -0700
  Re: readLine() and newline problem Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2019-05-10 09:02 +0200
    Re: readLine() and newline problem mike <mikaelpetterson@hotmail.com> - 2019-05-10 01:29 -0700
      Re: readLine() and newline problem Martin Gregorie <martin@mydomain.invalid> - 2019-05-10 10:22 +0000
      Re: readLine() and newline problem Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2019-05-10 18:50 +0200

csiph-web