bug-classpath
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug classpath/22930] FileInputStream.read(...) broken when underlying r


From: gcc-bugzilla at gcc dot gnu dot org
Subject: [Bug classpath/22930] FileInputStream.read(...) broken when underlying read returns 0 bytes
Date: 16 Oct 2005 01:27:42 -0000

The current versions of FileInputStream.read(...) are broken in the following
respect.

For FileInputStream.read():  this function simply calls C read() once and
returns the results.  However if the C read() returned 0 bytes read, then bad
data is returned in Java.  This is incorrect, as FileInputStream.read()
guarantees that it either returns a byte read or an error.  Thus,
FileInputStream.read() should poll until C read() returns non-zero bytes read.

For FileInputStream.read(buffer[], offset, length): this function has exactly
the opposite error.  Here the function blocks repeatedly until length bytes are
read or EOF occurs which is not the proper behavior.  If the stream for some
reason or another is constantly returning 0 bytes read -- as was the case in an
incorrectly-written /dev device we found recently -- FileInputStream.read(...)
will go into an infinite loop.  Instead, FileInputStream.read(...) should have
some way of (validly) returning less than length bytes if that was what was
provided it by the underlying C read() function.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22930





reply via email to

[Prev in Thread] Current Thread [Next in Thread]