cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From slebre...@apache.org
Subject git commit: Fix binary protocol bug, using singleton message by mistake
Date Tue, 30 Oct 2012 17:21:00 GMT
Updated Branches:
  refs/heads/trunk b74a00b28 -> 3b0aa84ca


Fix binary protocol bug, using singleton message by mistake


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

Branch: refs/heads/trunk
Commit: 3b0aa84ca3d70caeb2d818989ba9145fd836cd04
Parents: b74a00b
Author: Sylvain Lebresne <sylvain@datastax.com>
Authored: Tue Oct 30 18:20:43 2012 +0100
Committer: Sylvain Lebresne <sylvain@datastax.com>
Committed: Tue Oct 30 18:20:56 2012 +0100

----------------------------------------------------------------------
 .../org/apache/cassandra/cql3/QueryProcessor.java  |    2 +-
 .../org/apache/cassandra/transport/Message.java    |   11 +++++----
 .../transport/messages/ResultMessage.java          |   18 +++-----------
 3 files changed, 11 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/3b0aa84c/src/java/org/apache/cassandra/cql3/QueryProcessor.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/QueryProcessor.java b/src/java/org/apache/cassandra/cql3/QueryProcessor.java
index 29693dd..b306220 100644
--- a/src/java/org/apache/cassandra/cql3/QueryProcessor.java
+++ b/src/java/org/apache/cassandra/cql3/QueryProcessor.java
@@ -127,7 +127,7 @@ public class QueryProcessor
         statement.checkAccess(clientState);
         statement.validate(clientState);
         ResultMessage result = statement.execute(cl, clientState, variables);
-        return result == null ? ResultMessage.Void.instance() : result;
+        return result == null ? new ResultMessage.Void() : result;
     }
 
     public static ResultMessage process(String queryString, ConsistencyLevel cl, ClientState
clientState)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/3b0aa84c/src/java/org/apache/cassandra/transport/Message.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/transport/Message.java b/src/java/org/apache/cassandra/transport/Message.java
index 81df682..ff002f8 100644
--- a/src/java/org/apache/cassandra/transport/Message.java
+++ b/src/java/org/apache/cassandra/transport/Message.java
@@ -108,8 +108,8 @@ public abstract class Message
     }
 
     public final Type type;
-    protected Connection connection;
-    protected int streamId;
+    protected volatile Connection connection;
+    private volatile int streamId;
 
     protected Message(Type type)
     {
@@ -216,12 +216,12 @@ public abstract class Message
 
                 logger.debug("Responding: " + response);
 
-                e.getChannel().write(response);
+                ctx.getChannel().write(response);
             }
             catch (Exception ex)
             {
                 // Don't let the exception propagate to exceptionCaught() if we can help
it so that we can assign the right streamID.
-                e.getChannel().write(ErrorMessage.fromException(ex).setStreamId(request.getStreamId()));
+                ctx.getChannel().write(ErrorMessage.fromException(ex).setStreamId(request.getStreamId()));
             }
         }
 
@@ -229,7 +229,8 @@ public abstract class Message
         public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
         throws Exception
         {
-            ctx.getChannel().write(ErrorMessage.fromException(e.getCause()));
+            if (ctx.getChannel().isOpen())
+                ctx.getChannel().write(ErrorMessage.fromException(e.getCause()));
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/3b0aa84c/src/java/org/apache/cassandra/transport/messages/ResultMessage.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/transport/messages/ResultMessage.java b/src/java/org/apache/cassandra/transport/messages/ResultMessage.java
index 955abc6..57ba7dd 100644
--- a/src/java/org/apache/cassandra/transport/messages/ResultMessage.java
+++ b/src/java/org/apache/cassandra/transport/messages/ResultMessage.java
@@ -111,8 +111,9 @@ public abstract class ResultMessage extends Message.Response
 
     public static class Void extends ResultMessage
     {
-        // use VOID_MESSAGE
-        private Void()
+        // Even though we have no specific information here, don't make a
+        // singleton since as each message it has in fact a streamid and connection.
+        public Void()
         {
             super(Kind.VOID);
         }
@@ -121,7 +122,7 @@ public abstract class ResultMessage extends Message.Response
         {
             public ResultMessage decode(ChannelBuffer body)
             {
-                return Void.instance();
+                return new Void();
             }
 
             public ChannelBuffer encode(ResultMessage msg)
@@ -141,17 +142,6 @@ public abstract class ResultMessage extends Message.Response
             return new CqlResult(CqlResultType.VOID);
         }
 
-        public static Void instance()
-        {
-            return Holder.instance;
-        }
-
-        // Battling java initialization
-        private static class Holder
-        {
-            static final Void instance = new Void();
-        }
-
         @Override
         public String toString()
         {


Mime
View raw message