Browse Source

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>
stable-0.8
Shawn O. Pearce 15 years ago
parent
commit
f999b4aa63
  1. 14
      org.eclipse.jgit/src/org/eclipse/jgit/util/io/StreamCopyThread.java

14
org.eclipse.jgit/src/org/eclipse/jgit/util/io/StreamCopyThread.java

@ -100,11 +100,25 @@ public class StreamCopyThread extends Thread {
try { try {
n = src.read(buf); n = src.read(buf);
} catch (InterruptedIOException wakey) { } catch (InterruptedIOException wakey) {
if (flushCounter.get() > 0)
continue; continue;
else
throw wakey;
} }
if (n < 0) if (n < 0)
break; break;
for (;;) {
try {
dst.write(buf, 0, n); dst.write(buf, 0, n);
} catch (InterruptedIOException wakey) {
if (flushCounter.get() > 0)
continue;
else
throw wakey;
}
break;
}
} catch (IOException e) { } catch (IOException e) {
break; break;
} }

Loading…
Cancel
Save