summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMasaya Suzuki <draftcode@gmail.com>2016-08-19 13:51:05 -0700
committerMasaya Suzuki <draftcode@gmail.com>2016-08-19 14:09:17 -0700
commit108bee17cfb13624030a405681701a412ed76676 (patch)
treef954a564b9d24516bca6290be8f0cbd9bd052965
parent13f0db25f272e29b607c5b0e01a3b0d612731794 (diff)
downloadjgit-108bee17cfb13624030a405681701a412ed76676.tar.gz
jgit-108bee17cfb13624030a405681701a412ed76676.zip
Ignore IOException thrown from close
AddCommandTest is flaky because IOException is thrown sometimes. Caused by: java.io.IOException: Stream closed at java.lang.ProcessBuilder$NullOutputStream.write(ProcessBuilder.java:433) at java.io.OutputStream.write(OutputStream.java:116) at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82) at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:140) at java.io.FilterOutputStream.close(FilterOutputStream.java:158) at org.eclipse.jgit.util.FS.runProcess(FS.java:993) at org.eclipse.jgit.util.FS.execute(FS.java:1102) at org.eclipse.jgit.treewalk.WorkingTreeIterator.filterClean(WorkingTreeIterator.java:470) ... 22 more OpenJDK replaces the underlying OutputStream with NullOutputStream when the process exits. This throws IOException for all write operation. When it exits before JGit writes the input to the pipe buffer, the input stays in BufferedOutputStream. The close method tries to write it again, and IOException is thrown. Since we ignore IOException in StreamGobbler, we also ignore it when we close the stream. Fixes Bug 499633. Change-Id: I30c7ac78e05b00bd0152f697848f4d17d53efd17 Signed-off-by: Masaya Suzuki <draftcode@gmail.com>
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java11
1 files changed, 10 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 253acbb76a..ec587d5997 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java
@@ -990,7 +990,16 @@ public abstract class FS {
new StreamGobbler(inRedirect, outputStream)
.call();
}
- outputStream.close();
+ try {
+ outputStream.close();
+ } catch (IOException e) {
+ // When the process exits before consuming the input, the OutputStream
+ // is replaced with the null output stream. This null output stream
+ // throws IOException for all write calls. When StreamGobbler fails to
+ // flush the buffer because of this, this close call tries to flush it
+ // again. This causes another IOException. Since we ignore the
+ // IOException in StreamGobbler, we also ignore the exception here.
+ }
return process.waitFor();
} catch (IOException e) {
ioException = e;