From b3247ba5244d95e0d2c850a3fa1f69668a5790f5 Mon Sep 17 00:00:00 2001 From: Dmitry Neverov Date: Wed, 19 May 2010 11:39:17 -0700 Subject: [PATCH] Fix race condition in StreamCopyThread If we get an interrupt during an IO operation (src.read or dst.write) caused by the flush() method incrementing the flush counter, ensure we restart the proper section of code. Just ignore the interrupt and continue running. Bug: 313082 Change-Id: Ib2b37901af8141289bbac9807cacf42b4e2461bd Signed-off-by: Shawn O. Pearce --- .../src/org/eclipse/jgit/util/io/StreamCopyThread.java | 10 ++-------- 1 file changed, 2 insertions(+), 8 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 bf47d199a..c36835692 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,10 +100,7 @@ public void run() { try { n = src.read(buf); } catch (InterruptedIOException wakey) { - if (flushCounter.get() > 0) - continue; - else - throw wakey; + continue; } if (n < 0) break; @@ -112,10 +109,7 @@ public void run() { try { dst.write(buf, 0, n); } catch (InterruptedIOException wakey) { - if (flushCounter.get() > 0) - continue; - else - throw wakey; + continue; } break; }