]> source.dussan.org Git - jgit.git/commitdiff
Fix race condition in StreamCopyThread 28/728/1
authorDmitry Neverov <dmitry.neverov@gmail.com>
Wed, 19 May 2010 18:39:17 +0000 (11:39 -0700)
committerShawn O. Pearce <spearce@spearce.org>
Wed, 19 May 2010 18:40:33 +0000 (11:40 -0700)
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 <spearce@spearce.org>
org.eclipse.jgit/src/org/eclipse/jgit/util/io/StreamCopyThread.java

index bf47d199af68b66fe106f183e34cabb8fa59c933..c36835692ddd11b018e6a6ea0e7ed4d5519101a1 100644 (file)
@@ -100,10 +100,7 @@ public class StreamCopyThread extends Thread {
                                        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 class StreamCopyThread extends Thread {
                                                try {
                                                        dst.write(buf, 0, n);
                                                } catch (InterruptedIOException wakey) {
-                                                       if (flushCounter.get() > 0)
-                                                               continue;
-                                                       else
-                                                               throw wakey;
+                                                       continue;
                                                }
                                                break;
                                        }