summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShawn O. Pearce <spearce@spearce.org>2010-05-13 09:56:15 -0700
committerShawn O. Pearce <spearce@spearce.org>2010-05-13 09:58:21 -0700
commitf999b4aa63289cc5fb2941e9fa5f47e742e23fac (patch)
tree48963084136b8215fa897d3262917a72da47eff3
parent3f143b8d6b5c20098e041e22be42216e668a4a0b (diff)
downloadjgit-f999b4aa63289cc5fb2941e9fa5f47e742e23fac.tar.gz
jgit-f999b4aa63289cc5fb2941e9fa5f47e742e23fac.zip
Fix interrupted write in StreamCopyThread
If a flush() gets delivered at the same time that we are blocking while writing to an interruptable stream, the copy thread will abort assuming its a stream error. Instead ignore the interrupt, and retry the write. Change-Id: Icbf62d1b8abe0fabbb532dbee088020eecf4c6c2 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/util/io/StreamCopyThread.java18
1 files changed, 16 insertions, 2 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/io/StreamCopyThread.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/io/StreamCopyThread.java
index 50f42ad4fc..bf47d199af 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/util/io/StreamCopyThread.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/io/StreamCopyThread.java
@@ -100,11 +100,25 @@ public class StreamCopyThread extends Thread {
try {
n = src.read(buf);
} catch (InterruptedIOException wakey) {
- continue;
+ if (flushCounter.get() > 0)
+ continue;
+ else
+ throw wakey;
}
if (n < 0)
break;
- dst.write(buf, 0, n);
+
+ for (;;) {
+ try {
+ dst.write(buf, 0, n);
+ } catch (InterruptedIOException wakey) {
+ if (flushCounter.get() > 0)
+ continue;
+ else
+ throw wakey;
+ }
+ break;
+ }
} catch (IOException e) {
break;
}