United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-4779065 : (spec) InputStream.read() confused on return value of 0

Details
Type:
Bug
Submit Date:
2002-11-14
Status:
Resolved
Updated Date:
2003-05-16
Project Name:
JDK
Resolved Date:
2003-05-16
Component:
core-libs
OS:
generic
Sub-Component:
java.io
CPU:
generic
Priority:
P4
Resolution:
Fixed
Affected Versions:
1.2.1,1.4.2
Fixed Versions:
5.0 (tiger)

Related Reports
Relates:

Sub Tasks

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
EVALUATION

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

BugTraq+ Release Management Values

COMMIT TO FIX:
tiger

FIXED IN:
tiger

INTEGRATED IN:
tiger
tiger-b07


                                     
2004-06-14



Hardware and Software, Engineered to Work Together