cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sn...@apache.org
Subject cassandra git commit: Prevent duplicate ctx.channel().attr() call
Date Wed, 22 Jun 2016 10:37:57 GMT
Repository: cassandra
Updated Branches:
  refs/heads/trunk 9343bd407 -> 4ae198765


Prevent duplicate ctx.channel().attr() call

patch by Robert Stupp; reviewed by T Jake Luciani for CASSANDRA-11969


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

Branch: refs/heads/trunk
Commit: 4ae198765b21c644494cd902f6d127400d126de1
Parents: 9343bd40
Author: Robert Stupp <snazy@snazy.de>
Authored: Wed Jun 22 12:35:52 2016 +0200
Committer: Robert Stupp <snazy@snazy.de>
Committed: Wed Jun 22 12:35:52 2016 +0200

----------------------------------------------------------------------
 src/java/org/apache/cassandra/transport/Frame.java | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/4ae19876/src/java/org/apache/cassandra/transport/Frame.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/transport/Frame.java b/src/java/org/apache/cassandra/transport/Frame.java
index 363ff76..f620bc5 100644
--- a/src/java/org/apache/cassandra/transport/Frame.java
+++ b/src/java/org/apache/cassandra/transport/Frame.java
@@ -27,6 +27,7 @@ import io.netty.channel.*;
 import io.netty.handler.codec.ByteToMessageDecoder;
 import io.netty.handler.codec.MessageToMessageDecoder;
 import io.netty.handler.codec.MessageToMessageEncoder;
+import io.netty.util.Attribute;
 import org.apache.cassandra.config.DatabaseDescriptor;
 import org.apache.cassandra.exceptions.InvalidRequestException;
 import org.apache.cassandra.transport.messages.ErrorMessage;
@@ -223,12 +224,13 @@ public class Frame
             idx += bodyLength;
             buffer.readerIndex(idx);
 
-            Connection connection = ctx.channel().attr(Connection.attributeKey).get();
+            Attribute<Connection> attrConn = ctx.channel().attr(Connection.attributeKey);
+            Connection connection = attrConn.get();
             if (connection == null)
             {
                 // First message seen on this channel, attach the connection object
                 connection = factory.newConnection(ctx.channel(), version);
-                ctx.channel().attr(Connection.attributeKey).set(connection);
+                attrConn.set(connection);
             }
             else if (connection.getVersion() != version)
             {


Mime
View raw message