diff options
author | Robin Rosenberg <robin.rosenberg@dewire.com> | 2012-09-14 18:48:56 +0200 |
---|---|---|
committer | Shawn O. Pearce <spearce@spearce.org> | 2012-09-16 11:12:47 -0700 |
commit | caa362f20df1169e4a677648dce2af29d63cbcec (patch) | |
tree | dfbcfef7c4407e93132de6b14c24e04991474307 /org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/AmazonS3Client.java | |
parent | 1a07ddca859de9aedd0dbb1dddb254cd2430f13e (diff) | |
download | jgit-caa362f20df1169e4a677648dce2af29d63cbcec.tar.gz jgit-caa362f20df1169e4a677648dce2af29d63cbcec.zip |
Check for write errors in standard out and exit with error
The underlying problem is that System.out is a PrintWriter and
as such it does not throw exceptions on error, but rather just
sets a flag and continues.
This changes replaces the use of System.out with a PrintWriter-like
writer that does not catch error, but instead throw them to the
caller.
Bug: 366243
Change-Id: I44405edc4416e943b87f09a0f6ed041c6c51b046
Diffstat (limited to 'org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/AmazonS3Client.java')
-rw-r--r-- | org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/AmazonS3Client.java | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/AmazonS3Client.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/AmazonS3Client.java index cad4b63314..f137b10aca 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/AmazonS3Client.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/AmazonS3Client.java @@ -86,21 +86,23 @@ class AmazonS3Client extends TextBuiltin { int len = c.getContentLength(); final InputStream in = c.getInputStream(); try { + outw.flush(); final byte[] tmp = new byte[2048]; while (len > 0) { final int n = in.read(tmp); if (n < 0) throw new EOFException(MessageFormat.format(CLIText.get().expectedNumberOfbytes, len)); - System.out.write(tmp, 0, n); + outs.write(tmp, 0, n); len -= n; } + outs.flush(); } finally { in.close(); } } else if ("ls".equals(op) || "list".equals(op)) { for (final String k : s3.list(bucket, key)) - System.out.println(k); + outw.println(k); } else if ("rm".equals(op) || "delete".equals(op)) { s3.delete(bucket, key); |