Details
-
Type:
Defect
-
Status:
Closed
-
Priority:
Minor
-
Resolution: Declined
-
Affects Version/s: None
-
Fix Version/s: None
-
Component/s: None
-
Labels:None
Description
According to the interface http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#read()
InputStream.read() family of methods return -1 when the end of stream is reached.
do-copy methods currently use a test: (pos? size) to determine whether eos is reached. This mostly works, but the specification is pretty clear in that InputStream implementations are allowed to return reads of zero bytes before returning more bytes.
##EDIT changed title of ticket from "clojure.java.io/copy should test for -1 instead of 0 for end of stream"
I reread the spec for InputStream.read and it clearly says
"If no byte is available because the stream is at the end of the file, the value -1 is returned; otherwise, at least one byte is read and stored into b."
The reason I originally thought of this as an issue was a misbehaving ServletInputStream from Jetty.
I closed the issue as declined. Sorry for the noise!