diff options
author | Zhen Chen <czhen@google.com> | 2016-10-31 14:27:36 -0700 |
---|---|---|
committer | Zhen Chen <czhen@google.com> | 2016-10-31 14:31:48 -0700 |
commit | feefcb02b0215b6dea9be5efbb9a3f4048d8c0ff (patch) | |
tree | e77eb11373e95ace9715a4a8658c072e6133d6e4 /org.eclipse.jgit/src | |
parent | 83555e7e303b45b9a96fbae4a7ebbff3cdb83b1c (diff) | |
download | jgit-feefcb02b0215b6dea9be5efbb9a3f4048d8c0ff.tar.gz jgit-feefcb02b0215b6dea9be5efbb9a3f4048d8c0ff.zip |
Fix flush call race condition in StreamCopyThread
If there was a new flush() call during flush previous bytes, we need to
catch it in order to process the new bytes between the two flush()
calls instead of going to last catch IOException clause and end the
thread.
Change-Id: Ibc58a1fa97559238c13590aedbb85e482d85e465
Signed-off-by: Zhen Chen <czhen@google.com>
Diffstat (limited to 'org.eclipse.jgit/src')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/util/io/StreamCopyThread.java | 8 |
1 files changed, 7 insertions, 1 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 8d39a22ac2..eabe72b252 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 @@ -118,7 +118,13 @@ public class StreamCopyThread extends Thread { for (;;) { try { if (readInterrupted) { - dst.flush(); + try { + dst.flush(); + } catch (InterruptedIOException e) { + // There was a new flush() call during flush previous bytes + // need continue read/write/flush for the new bytes + continue; + } readInterrupted = false; if (!flushCount.compareAndSet(flushCountBeforeRead, 0)) { // There was a flush() call since last blocked read. |