JDK-4779065 : (spec) InputStream.read() confused on return value of 0
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.io
  • Affected Version: 1.2.1,1.4.2
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2002-11-14
  • Updated: 2017-05-16
  • Resolved: 2003-05-16
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availabitlity Release.

To download the current JDK release, click here.
Other
5.0 tigerFixed
Related Reports
Relates :  
Description
The expected behaviour for InputStream.read when no bytes can be read is
unclear.  In jdk1.2, the following two sentences in the specification were
introduced.  They need to be resolved.

  An attempt is made to read as many as
  <code>len</code> bytes, but a smaller number may be read, possibly zero.

  If the first byte cannot be read for any reason other than end of
  file, then an <code>IOException</code> is thrown.

So, if no bytes are read, should InputStream.read return 0 or throw an
IOException?  Since jdk1.1.8, the behavior has been to return -1 which would
indicate that an eof has been found. As of mantis-beta it throws an IOException
due to the fix for 4684515.

-- iag@sfbay 2002-11-14

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: tiger FIXED IN: tiger INTEGRATED IN: tiger tiger-b07
2004-06-14

EVALUATION The submitter is correct. -- ###@###.### 2002/11/15
181-10-11 0