summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit
diff options
context:
space:
mode:
authorBryan Donlan <bdonlan@gmail.com>2017-05-22 11:37:14 -0700
committerMatthias Sohn <matthias.sohn@sap.com>2017-05-24 23:35:39 +0200
commit2204cc986649265fd2748557f05f4521f177fa98 (patch)
tree7b5eb7432d277553748ce2b62a24d6ae47dc661b /org.eclipse.jgit
parenta46b28808b303d326eb79c7a42aec0147e171a39 (diff)
downloadjgit-2204cc986649265fd2748557f05f4521f177fa98.tar.gz
jgit-2204cc986649265fd2748557f05f4521f177fa98.zip
Fix null return from FS.readPipe when command fails to launch
When a command invoked from readPipe fails to launch (i.e. the exec call fails due to a missing command executable), Process.start() throws, which gets caught by the generic IOException handler, resulting in a null return. This change detects this case and rethrows a CommandFailedException instead. Additionally, this change uses /bin/sh instead of bash for its posix command failure test, to accomodate building in environments where bash is unavailable. Change-Id: Ifae51e457e5718be610c0a0914b18fe35ea7b008 Signed-off-by: Bryan Donlan <bdonlan@gmail.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java8
1 files changed, 7 insertions, 1 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java
index 229355c50a..1cc39bd46c 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java
@@ -497,7 +497,13 @@ public abstract class FS {
if (env != null) {
pb.environment().putAll(env);
}
- Process p = pb.start();
+ Process p;
+ try {
+ p = pb.start();
+ } catch (IOException e) {
+ // Process failed to start
+ throw new CommandFailedException(-1, e.getMessage(), e);
+ }
p.getOutputStream().close();
GobblerThread gobbler = new GobblerThread(p, command, dir);
gobbler.start();