[FIXED JENKINS-8686]

As I mentioned in the comment, I doubt if this makes any behaviour change, but this seems like a sensible defensive measure that wouldn't hurt.
This commit is contained in:
Kohsuke Kawaguchi 2013-04-02 09:58:20 -07:00
parent 548373fad1
commit dc94b7d063
5 changed files with 7 additions and 7 deletions

View File

@ -300,14 +300,14 @@ public class CLI {
byte[] buf = new byte[1024];
try {
InputStream is = conn.getInputStream();
while (is.read(buf) > 0) {
while (is.read(buf) >= 0) {
// Ignore
}
is.close();
} catch (IOException e) {
try {
InputStream es = ((HttpURLConnection)conn).getErrorStream();
while (es.read(buf) > 0) {
while (es.read(buf) >= 0) {
// Ignore
}
es.close();

View File

@ -399,7 +399,7 @@ public abstract class Proc {
try {
byte[] buf = new byte[8192];
int len;
while ((len = in.read(buf)) > 0) {
while ((len = in.read(buf)) >= 0) {
out.write(buf, 0, len);
out.flush();
}

View File

@ -451,7 +451,7 @@ public class Util {
public static void copyStream(InputStream in,OutputStream out) throws IOException {
byte[] buf = new byte[8192];
int len;
while((len=in.read(buf))>0)
while((len=in.read(buf))>=0)
out.write(buf,0,len);
}
@ -562,7 +562,7 @@ public class Util {
byte[] buffer = new byte[1024];
DigestInputStream in =new DigestInputStream(source,md5);
try {
while(in.read(buffer)>0)
while(in.read(buffer)>=0)
; // simply discard the input
} finally {
in.close();

View File

@ -57,7 +57,7 @@ public class StreamCopyThread extends Thread {
try {
byte[] buf = new byte[8192];
int len;
while ((len = in.read(buf)) > 0)
while ((len = in.read(buf)) >= 0)
out.write(buf, 0, len);
} finally {
// it doesn't make sense not to close InputStream that's already EOF-ed,

View File

@ -71,7 +71,7 @@ final class ZipArchiver extends Archiver {
zip.putNextEntry(fileZipEntry);
FileInputStream in = new FileInputStream(f);
int len;
while((len=in.read(buf))>0)
while((len=in.read(buf))>=0)
zip.write(buf,0,len);
in.close();
zip.closeEntry();