diff options
author | Christian Halstrick <christian.halstrick@sap.com> | 2015-11-24 11:18:59 +0100 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2015-11-26 00:36:09 +0100 |
commit | 55fb18feaa096b47acebbc8fb8c37942d68f49d5 (patch) | |
tree | b77a09c0df1eb8a6079cc33393dee7f5d65e3ceb /org.eclipse.jgit | |
parent | fe98218e0df85012cb9b901c71c44f232f65cb3a (diff) | |
download | jgit-55fb18feaa096b47acebbc8fb8c37942d68f49d5.tar.gz jgit-55fb18feaa096b47acebbc8fb8c37942d68f49d5.zip |
Fix FS.runProcess() to close the InputStream
When FS.runProcess was called and an InputStream was given the method
tried to pump the whole InputStream to the process. When the method
ended the InputStream was not giving any data anymore. Consequently
close the InputStream inside the method.
Change-Id: I0ed738a775e5c977b21447d195acee1ecf5e2cb9
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java | 13 |
1 files changed, 7 insertions, 6 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 b61e47f5f6..253acbb76a 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java @@ -949,9 +949,7 @@ public abstract class FS { * @param outRedirect * An OutputStream on which to redirect the processes stdout. Can * be <code>null</code>, in which case the processes standard - * output will be lost. If binary is set to <code>false</code> - * then it is expected that the process emits text data which - * should be processed line by line. + * output will be lost. * @param errRedirect * An OutputStream on which to redirect the processes stderr. Can * be <code>null</code>, in which case the processes standard @@ -959,9 +957,9 @@ public abstract class FS { * @param inRedirect * An InputStream from which to redirect the processes stdin. Can * be <code>null</code>, in which case the process doesn't get - * any data over stdin. If binary is set to - * <code>false</code> then it is expected that the process - * expects text data which should be processed line by line. + * any data over stdin. It is assumed that the whole InputStream + * will be consumed by the process. The method will close the + * inputstream after all bytes are read. * @return the return code of this process. * @throws IOException * if an I/O error occurs while executing this process. @@ -1011,6 +1009,9 @@ public abstract class FS { // A process doesn't clean its own resources even when destroyed // Explicitly try and close all three streams, preserving the // outer I/O exception if any. + if (inRedirect != null) { + inRedirect.close(); + } try { process.getErrorStream().close(); } catch (IOException e) { |