JENKINS-8686 IO stream copies are not done properly.

First pass at making sure we don't stop copying when the reader reads 0 characters.

I will now also review the callers for our internal code, and check if we can use IOUtils methods instead.
This commit is contained in:
Jerome Lacoste committed 2011-02-04 15:34:07 +01:00
1 parent 2332b114a3
commit bfbaf2c9d9
16 files changed
+50 -35

No files matched your search

@@ -46,11 +46,14 @@ class Copier extends Thread {
try {
byte[] buf = new byte[8192];
int len;
while((len=in.read(buf))>0)
out.write(buf,0,len);
in.close();
try {
while((len=in.read(buf))>=0)
out.write(buf,0,len);
} finally {
in.close();
}
} catch (IOException e) {
// TODO: what to do?
throw new RuntimeException(e);
}
}
}
@@ -45,9 +45,12 @@ public class TestCallable implements Callable {
byte[] buf = new byte[8192];
int len;
while((len=in.read(buf))>0)
baos.write(buf,0,len);
in.close();
try {
while((len=in.read(buf))>=0)
baos.write(buf,0,len);
} finally {
in.close();
}
r[1] = baos.toByteArray();