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


##########
src/java/org/apache/cassandra/net/Message.java:
##########
@@ -729,20 +728,27 @@ public <T> Message<T> deserialize(DataInputPlus in, 
InetAddressAndPort peer, int
          */
         public <T> Message<T> deserialize(DataInputPlus in, Header header, int 
version) throws IOException
         {
-            return version >= VERSION_40 ? deserializePost40(in, header, 
version) : deserializePre40(in, header, version);
+            skipHeader(in);
+            skipUnsignedVInt(in); // payload size, not needed by payload 
deserializer
+            T payload = (T) header.verb.serializer().deserialize(in, version);
+            return new Message<>(header, payload);
         }
 
         private <T> int serializedSize(Message<T> message, int version)
         {
-            return version >= VERSION_40 ? serializedSizePost40(message, 
version) : serializedSizePre40(message, version);
+            long size = 0;
+            size += serializedHeader(message.header, version);
+            int payloadSize = message.payloadSize(version);
+            size += sizeofUnsignedVInt(payloadSize) + payloadSize;
+            return Ints.checkedCast(size);
         }
 
         /**
          * Size of the next message in the stream. Returns -1 if there aren't 
sufficient bytes read yet to determine size.
          */
         int inferMessageSize(ByteBuffer buf, int index, int limit, int 
version) throws InvalidLegacyProtocolMagic

Review Comment:
   `version` and `InvalidLegacyProtocolMagic` are not used and probably can be 
removed from the method signature.



-- 
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