Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8286200

SequenceInputStream::read(b, off, 0) returns -1 at EOF

    XMLWordPrintable

    Details

    • Type: Enhancement
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 19
    • Component/s: core-libs
    • Subcomponent:
    • Resolved In Build:
      b23

      Description

      As per spec - https://download.java.net/java/early_access/jdk19/docs/api/java.base/java/io/InputStream.html#read(byte%5B%5D,int,int)

      "If len is zero, then no bytes are read and 0 is returned; otherwise, there is an attempt to read at least one byte. If no byte is available because the stream is at end of file, the value -1 is returned; otherwise, at least one byte is read and stored into b."

      One case which looks ambiguous is -
      Case - when stream is at the end of file and the length is zero, what is the expected value is it 0 or -1?

      Observation is - ObjectInputStream is returning 0 at EOF when length is zero, SequenceInputStream returns -1 at EOF when length is zero.

      Can you please clarify what is the expected behavior in this case? Is there any scope for spec improvements here?

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              bpb Brian Burkhalter
              Reporter:
              kganapureddy Krushnareddy Ganapureddy
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: