cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From marc...@apache.org
Subject git commit: Fix infinite loop on exception while streaming
Date Tue, 03 Jun 2014 06:14:15 GMT
Repository: cassandra
Updated Branches:
  refs/heads/cassandra-2.0 62d9c4367 -> 58bb974a3


Fix infinite loop on exception while streaming

Patch by JoshuaMcKenzie; reviewed by marcuse for CASSANDRA-7330


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/58bb974a
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/58bb974a
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/58bb974a

Branch: refs/heads/cassandra-2.0
Commit: 58bb974a330ab71d2ee34cace565f489e26629c7
Parents: 62d9c43
Author: Marcus Eriksson <marcuse@apache.org>
Authored: Tue Jun 3 07:54:21 2014 +0200
Committer: Marcus Eriksson <marcuse@apache.org>
Committed: Tue Jun 3 08:01:34 2014 +0200

----------------------------------------------------------------------
 CHANGES.txt                                          |  1 +
 .../org/apache/cassandra/streaming/StreamReader.java | 15 +++++++++++++--
 2 files changed, 14 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/58bb974a/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index bc95a8d..37105f3 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -11,6 +11,7 @@
  * Add authentication support to shuffle (CASSANDRA-6484)
  * Cqlsh counts non-empty lines for "Blank lines" warning (CASSANDRA-7325)
  * Make StreamSession#closeSession() idempotent (CASSANDRA-7262)
+ * Fix infinite loop on exception while streaming (CASSANDRA-7330)
 Merged from 1.2:
  * Fix availability validation for LOCAL_ONE CL (CASSANDRA-7319)
  * Use LOCAL_ONE for non-superuser auth queries (CASSANDRA-7328)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/58bb974a/src/java/org/apache/cassandra/streaming/StreamReader.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/streaming/StreamReader.java b/src/java/org/apache/cassandra/streaming/StreamReader.java
index 72c239c..15aa3cb 100644
--- a/src/java/org/apache/cassandra/streaming/StreamReader.java
+++ b/src/java/org/apache/cassandra/streaming/StreamReader.java
@@ -114,9 +114,20 @@ public class StreamReader
     protected void drain(InputStream dis, long bytesRead) throws IOException
     {
         long toSkip = totalSize() - bytesRead;
-        toSkip = toSkip - dis.skip(toSkip);
+
+        // InputStream.skip can return -1 if dis is inaccessible.
+        long skipped = dis.skip(toSkip);
+        if (skipped == -1)
+            return;
+
+        toSkip = toSkip - skipped;
         while (toSkip > 0)
-            toSkip = toSkip - dis.skip(toSkip);
+        {
+            skipped = dis.skip(toSkip);
+            if (skipped == -1)
+                break;
+            toSkip = toSkip - skipped;
+        }
     }
 
     protected long totalSize()


Mime
View raw message