cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yu...@apache.org
Subject [02/10] cassandra git commit: Fix handling of streaming EOF
Date Tue, 01 Sep 2015 22:01:47 GMT
Fix handling of streaming EOF

patch by Alexey Burylov; reviewed by yukim for CASSANDRA-10206


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

Branch: refs/heads/cassandra-2.2
Commit: 2267d79188c4388674ea40268a12f9c19f0fb9a7
Parents: 542bb1f
Author: Alexey Burylov <a.burylov@qiwi.ru>
Authored: Tue Sep 1 12:18:17 2015 -0500
Committer: Yuki Morishita <yukim@apache.org>
Committed: Tue Sep 1 12:18:17 2015 -0500

----------------------------------------------------------------------
 CHANGES.txt                                          |  1 +
 .../cassandra/streaming/messages/StreamMessage.java  | 15 ++++++++++-----
 2 files changed, 11 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/2267d791/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 7841f9b..681a40b 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 2.1.10
+ * Fix handling of streaming EOF (CASSANDRA-10206)
  * Only check KeyCache when it is enabled
  * Change streaming_socket_timeout_in_ms default to 1 hour (CASSANDRA-8611)
  * (cqlsh) update list of CQL keywords (CASSANDRA-9232)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/2267d791/src/java/org/apache/cassandra/streaming/messages/StreamMessage.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/streaming/messages/StreamMessage.java b/src/java/org/apache/cassandra/streaming/messages/StreamMessage.java
index 360b59e..9724bf1 100644
--- a/src/java/org/apache/cassandra/streaming/messages/StreamMessage.java
+++ b/src/java/org/apache/cassandra/streaming/messages/StreamMessage.java
@@ -18,9 +18,9 @@
 package org.apache.cassandra.streaming.messages;
 
 import java.io.IOException;
+import java.net.SocketException;
 import java.nio.ByteBuffer;
 import java.nio.channels.ReadableByteChannel;
-import java.nio.channels.WritableByteChannel;
 
 import org.apache.cassandra.io.util.DataOutputStreamAndChannel;
 import org.apache.cassandra.streaming.StreamSession;
@@ -48,18 +48,23 @@ public abstract class StreamMessage
     public static StreamMessage deserialize(ReadableByteChannel in, int version, StreamSession
session) throws IOException
     {
         ByteBuffer buff = ByteBuffer.allocate(1);
-        if (in.read(buff) > 0)
+        int readBytes = in.read(buff);
+        if (readBytes > 0)
         {
             buff.flip();
             Type type = Type.get(buff.get());
             return type.inSerializer.deserialize(in, version, session);
         }
-        else
+        else if (readBytes == 0)
         {
-            // when socket gets closed, there is a chance that buff is empty
-            // in that case, just return null
+            // input socket buffer was not filled yet
             return null;
         }
+        else
+        {
+            // possibly socket gets closed
+            throw new SocketException("End-of-stream reached");
+        }
     }
 
     /** StreamMessage serializer */


Mime
View raw message