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.test | |
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.test')
-rw-r--r-- | org.eclipse.jgit.pgm.test/META-INF/MANIFEST.MF | 1 | ||||
-rw-r--r-- | org.eclipse.jgit.pgm.test/src/org/eclipse/jgit/pgm/CLIGitCommand.java | 12 |
2 files changed, 5 insertions, 8 deletions
diff --git a/org.eclipse.jgit.pgm.test/META-INF/MANIFEST.MF b/org.eclipse.jgit.pgm.test/META-INF/MANIFEST.MF index 0e8ebc6fa1..61007f98b2 100644 --- a/org.eclipse.jgit.pgm.test/META-INF/MANIFEST.MF +++ b/org.eclipse.jgit.pgm.test/META-INF/MANIFEST.MF @@ -15,6 +15,7 @@ Import-Package: org.eclipse.jgit.api;version="[2.1.0,2.2.0)", org.eclipse.jgit.revwalk;version="[2.1.0,2.2.0)", org.eclipse.jgit.storage.file;version="[2.1.0,2.2.0)", org.eclipse.jgit.util;version="[2.1.0,2.2.0)", + org.eclipse.jgit.util.io;version="[2.1.0,2.2.0)", org.hamcrest.core;bundle-version="[1.1.0,2.0.0)", org.junit;version="[4.4.0,5.0.0)", org.kohsuke.args4j;version="[2.0.12,2.1.0)", diff --git a/org.eclipse.jgit.pgm.test/src/org/eclipse/jgit/pgm/CLIGitCommand.java b/org.eclipse.jgit.pgm.test/src/org/eclipse/jgit/pgm/CLIGitCommand.java index 28339c71e3..78e752d44e 100644 --- a/org.eclipse.jgit.pgm.test/src/org/eclipse/jgit/pgm/CLIGitCommand.java +++ b/org.eclipse.jgit.pgm.test/src/org/eclipse/jgit/pgm/CLIGitCommand.java @@ -42,10 +42,7 @@ */ package org.eclipse.jgit.pgm; -import java.io.BufferedWriter; import java.io.ByteArrayOutputStream; -import java.io.OutputStreamWriter; -import java.io.PrintWriter; import java.util.ArrayList; import java.util.List; @@ -84,21 +81,20 @@ public class CLIGitCommand { clp.parseArgument(argv); final TextBuiltin cmd = bean.getSubcommand(); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + cmd.outs = baos; if (cmd.requiresRepository()) cmd.init(db, null); else cmd.init(null, null); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - cmd.out = new PrintWriter(new BufferedWriter(new OutputStreamWriter( - baos))); try { cmd.execute(bean.getArguments().toArray( new String[bean.getArguments().size()])); } catch (Die e) { return IO.readLines(e.getMessage()); } finally { - if (cmd.out != null) - cmd.out.flush(); + if (cmd.outw != null) + cmd.outw.flush(); } return IO.readLines(baos.toString()); } |