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

XMLWordPrintable

    • b23

      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?

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

              Created:
              Updated:
              Resolved: