[CLJ-1089] clojure.java.io/copy interprets read count of 0 as eos Created: 22/Oct/12 Updated: 22/Oct/12 Resolved: 22/Oct/12 |
|
| Status: | Closed |
| Project: | Clojure |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Defect | Priority: | Minor |
| Reporter: | Herwig Hochleitner | Assignee: | Unassigned |
| Resolution: | Declined | Votes: | 0 |
| Labels: | None | ||
| Attachments: |
|
| Description |
|
According to the interface http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#read() 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" |
| Comments |
| Comment by Herwig Hochleitner [ 22/Oct/12 3:40 PM ] |
|
Attached patch changes do-copy methods to test for -1 |
| Comment by Andy Fingerhut [ 22/Oct/12 4:56 PM ] |
|
Herwig, can you elaborate on "the specification is pretty clear in that InputStream implementations are allowed to return reads of zero bytes before returning more bytes"? I ask because in the very InputStream documentation page you link to, it seems to explicitly say the opposite of what you claim: "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." |
| Comment by Herwig Hochleitner [ 22/Oct/12 4:57 PM ] |
|
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! |