Mmuzaf commented on code in PR #2506:
URL: https://github.com/apache/cassandra/pull/2506#discussion_r1272587795


##########
src/java/org/apache/cassandra/net/InboundConnectionInitiator.java:
##########
@@ -321,78 +319,42 @@ void initiate(ChannelHandlerContext ctx, ByteBuf in) 
throws IOException
                 return;
             }
 
-            if (initiate.acceptVersions != null)
-            {
-                logger.trace("Connection version {} (min {}) from {}", 
initiate.acceptVersions.max, initiate.acceptVersions.min, initiate.from);
+            assert initiate.acceptVersions != null;
+            logger.trace("Connection version {} (min {}) from {}", 
initiate.acceptVersions.max, initiate.acceptVersions.min, initiate.from);
 
-                final AcceptVersions accept;
+            final AcceptVersions accept;
 
-                if (initiate.type.isStreaming())
-                    accept = settings.acceptStreaming;
-                else
-                    accept = settings.acceptMessaging;
+            if (initiate.type.isStreaming())
+                accept = settings.acceptStreaming;
+            else
+                accept = settings.acceptMessaging;
 
-                int useMessagingVersion = max(accept.min, min(accept.max, 
initiate.acceptVersions.max));
-                ByteBuf flush = new 
HandshakeProtocol.Accept(useMessagingVersion, accept.max).encode(ctx.alloc());
+            int useMessagingVersion = max(accept.min, min(accept.max, 
initiate.acceptVersions.max));
+            ByteBuf flush = new HandshakeProtocol.Accept(useMessagingVersion, 
accept.max).encode(ctx.alloc());
 
-                AsyncChannelPromise.writeAndFlush(ctx, flush, 
(ChannelFutureListener) future -> {
-                    if (!future.isSuccess())
-                        exceptionCaught(future.channel(), future.cause());
-                });
+            AsyncChannelPromise.writeAndFlush(ctx, flush, 
(ChannelFutureListener) future -> {
+                if (!future.isSuccess())
+                    exceptionCaught(future.channel(), future.cause());
+            });
 
-                if (initiate.acceptVersions.min > accept.max)
-                {
-                    logger.info("peer {} only supports messaging versions 
higher ({}) than this node supports ({})", ctx.channel().remoteAddress(), 
initiate.acceptVersions.min, current_version);
-                    failHandshake(ctx);
-                    return;
-                }
-                else if (initiate.acceptVersions.max < accept.min)
-                {
-                    logger.info("peer {} only supports messaging versions 
lower ({}) than this node supports ({})", ctx.channel().remoteAddress(), 
initiate.acceptVersions.max, minimum_version);
-                    failHandshake(ctx);
-                    return;
-                }
-                else
-                {
-                    if (initiate.type.isStreaming())
-                        setupStreamingPipeline(initiate.from, ctx);
-                    else
-                        setupMessagingPipeline(initiate.from, 
useMessagingVersion, initiate.acceptVersions.max, ctx.pipeline());
-                }
+            if (initiate.acceptVersions.min > accept.max)
+            {
+                logger.info("peer {} only supports messaging versions higher 
({}) than this node supports ({})", ctx.channel().remoteAddress(), 
initiate.acceptVersions.min, current_version);
+                failHandshake(ctx);
+                return;

Review Comment:
   `return` is unnecessary now



##########
src/java/org/apache/cassandra/net/InboundConnectionInitiator.java:
##########
@@ -321,78 +319,42 @@ void initiate(ChannelHandlerContext ctx, ByteBuf in) 
throws IOException
                 return;
             }
 
-            if (initiate.acceptVersions != null)
-            {
-                logger.trace("Connection version {} (min {}) from {}", 
initiate.acceptVersions.max, initiate.acceptVersions.min, initiate.from);
+            assert initiate.acceptVersions != null;
+            logger.trace("Connection version {} (min {}) from {}", 
initiate.acceptVersions.max, initiate.acceptVersions.min, initiate.from);
 
-                final AcceptVersions accept;
+            final AcceptVersions accept;
 
-                if (initiate.type.isStreaming())
-                    accept = settings.acceptStreaming;
-                else
-                    accept = settings.acceptMessaging;
+            if (initiate.type.isStreaming())
+                accept = settings.acceptStreaming;
+            else
+                accept = settings.acceptMessaging;
 
-                int useMessagingVersion = max(accept.min, min(accept.max, 
initiate.acceptVersions.max));
-                ByteBuf flush = new 
HandshakeProtocol.Accept(useMessagingVersion, accept.max).encode(ctx.alloc());
+            int useMessagingVersion = max(accept.min, min(accept.max, 
initiate.acceptVersions.max));
+            ByteBuf flush = new HandshakeProtocol.Accept(useMessagingVersion, 
accept.max).encode(ctx.alloc());
 
-                AsyncChannelPromise.writeAndFlush(ctx, flush, 
(ChannelFutureListener) future -> {
-                    if (!future.isSuccess())
-                        exceptionCaught(future.channel(), future.cause());
-                });
+            AsyncChannelPromise.writeAndFlush(ctx, flush, 
(ChannelFutureListener) future -> {
+                if (!future.isSuccess())
+                    exceptionCaught(future.channel(), future.cause());
+            });
 
-                if (initiate.acceptVersions.min > accept.max)
-                {
-                    logger.info("peer {} only supports messaging versions 
higher ({}) than this node supports ({})", ctx.channel().remoteAddress(), 
initiate.acceptVersions.min, current_version);
-                    failHandshake(ctx);
-                    return;
-                }
-                else if (initiate.acceptVersions.max < accept.min)
-                {
-                    logger.info("peer {} only supports messaging versions 
lower ({}) than this node supports ({})", ctx.channel().remoteAddress(), 
initiate.acceptVersions.max, minimum_version);
-                    failHandshake(ctx);
-                    return;
-                }
-                else
-                {
-                    if (initiate.type.isStreaming())
-                        setupStreamingPipeline(initiate.from, ctx);
-                    else
-                        setupMessagingPipeline(initiate.from, 
useMessagingVersion, initiate.acceptVersions.max, ctx.pipeline());
-                }
+            if (initiate.acceptVersions.min > accept.max)
+            {
+                logger.info("peer {} only supports messaging versions higher 
({}) than this node supports ({})", ctx.channel().remoteAddress(), 
initiate.acceptVersions.min, current_version);
+                failHandshake(ctx);
+                return;
+            }
+            else if (initiate.acceptVersions.max < accept.min)
+            {
+                logger.info("peer {} only supports messaging versions lower 
({}) than this node supports ({})", ctx.channel().remoteAddress(), 
initiate.acceptVersions.max, minimum_version);
+                failHandshake(ctx);
+                return;

Review Comment:
   `return` is unnecessary now



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to