Reported at https://ask.clojure.org/index.php/8450/strange-behavior-with-clojure-java-io-copy
Actual copying is implemented by reading bytes from an InputStream and writing to an OutputStream. The copy loop terminates if the bytes read is not >0. However, 0 is a legal return value (only -1 indicates EOF).
Approach: Termination condition should be >= 0, not > 0.
Patch: clj-2533-2.patch
Two things:
Several people seem to think that you’ll only get zero back if the buffer has size zero and that you’ll potentially get an infinite loop if you continuing reading after a zero size result (based on the Java API docs, I’m inclined to agree).
Is this code correct in the patch?
Should the (is (instance? ,,,)) line be inside the try?
Also, the resource changes seem unrelated to this ticket so they presumably should not be part of this patch?
Re 2, it's not correct, and it's actually a separate patch for CLJ-2431, fixed.