[kaffe] Problem with BufferedInputStream [patch]
mark at klomp.org
Thu Jun 5 05:39:02 PDT 2003
I tried to get my java bittorrent project (http://www.klomp.org/snark/),
working with kaffe and found a problem with BufferedInputStream. The
code contains the following construct (simplified, the real code uses a
public class ReadLineTest
public static void main(String args) throws Exception
InputStream in = System.in;
BufferedInputStream bis = new BufferedInputStream(in);
BufferedReader br = new BufferedReader
(new InputStreamReader(bis, "US-ASCII"));
String line = br.readLine();
The expected behaviour is for the program to read a line and print it.
But readLine() will not return with the first line till at least 2048
characters have been input (which can be multiple lines).
The problem is in BufferedInputStream._read(byte b, int off, int len).
Which tries to fill the given byte with len bytes even if it has
buffered less bytes (so it will keep readingfrom the underlying
The attached patch removes the while (len > 0) construct which makes the
above program (and The Hunting of the Snark Project) work correctly.
Mauve and make check results do not show regressions with this change.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 2098 bytes
Desc: not available
Url : http://kaffe.org/pipermail/kaffe/attachments/20030605/de447197/attachment-0002.bin
More information about the kaffe