From cec4253ba83be62dff17894442dbd1bb0690aaed Mon Sep 17 00:00:00 2001 From: Vijay Parthasarathy Date: Fri, 30 Mar 2012 11:42:10 -0700 Subject: [PATCH] CASSANDRA-4099-reopened patch by Vijay; reviewed by Brandon Williams for CASSANDRA-4098 --- .../cassandra/net/IncomingTcpConnection.java | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/java/org/apache/cassandra/net/IncomingTcpConnection.java b/src/java/org/apache/cassandra/net/IncomingTcpConnection.java index 47ab39a663..a9a5809168 100644 --- a/src/java/org/apache/cassandra/net/IncomingTcpConnection.java +++ b/src/java/org/apache/cassandra/net/IncomingTcpConnection.java @@ -92,19 +92,16 @@ public class IncomingTcpConnection extends Thread // we should buffer input = new DataInputStream(new BufferedInputStream(socket.getInputStream(), 4096)); // Receive the first message to set the version. - Message msg = receiveMessage(input, version); - from = msg.getFrom(); // why? see => CASSANDRA-4099 + from = receiveMessage(input, version); // why? see => CASSANDRA-4099 if (version > MessagingService.version_) { // save the endpoint so gossip will reconnect to it Gossiper.instance.addSavedEndpoint(from); logger.info("Received " + (isStream ? "streaming " : "") + "connection from newer protocol version. Ignoring"); + return; } - else if (msg != null) - { - Gossiper.instance.setVersion(from, version); - logger.debug("set version for {} to {}", from, version); - } + Gossiper.instance.setVersion(from, version); + logger.debug("set version for {} to {}", from, version); // loop to get the next message. while (true) @@ -133,7 +130,7 @@ public class IncomingTcpConnection extends Thread } } - private Message receiveMessage(DataInputStream input, int version) throws IOException + private InetAddress receiveMessage(DataInputStream input, int version) throws IOException { int totalSize = input.readInt(); String id = input.readUTF(); @@ -158,10 +155,12 @@ public class IncomingTcpConnection extends Thread { Message message = new Message(header, body, version); MessagingService.instance().receive(message, id); - return message; } - logger.debug("Received connection from newer protocol version {}. Ignoring message", version); - return null; + else + { + logger.debug("Received connection from newer protocol version {}. Ignoring message", version); + } + return header.getFrom(); } private void close()