You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@eventmesh.apache.org by "xwm1992 (via GitHub)" <gi...@apache.org> on 2023/03/08 03:00:25 UTC
[GitHub] [incubator-eventmesh] xwm1992 commented on a diff in pull request #3344: [ISSUE #3343]Optimize Codec.Encoder and Codec.Decoder
xwm1992 commented on code in PR #3344:
URL: https://github.com/apache/incubator-eventmesh/pull/3344#discussion_r1128918966
##########
eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/tcp/codec/Codec.java:
##########
@@ -74,12 +74,20 @@ public void encode(ChannelHandlerContext ctx, Package pkg, ByteBuf out) throws E
int headerLength = ArrayUtils.getLength(headerData);
int bodyLength = ArrayUtils.getLength(bodyData);
- int length = 4 + 4 + headerLength + bodyLength;
+ int length = headerLength + bodyLength;
Review Comment:
this line need to change:
`int length = CONSTANT_MAGIC_FLAG.length + VERSION.length + headerLength + bodyLength;`
##########
eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/tcp/codec/Codec.java:
##########
@@ -108,14 +116,14 @@ public void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) thro
final int length = in.readInt();
final int headerLength = in.readInt();
- final int bodyLength = length - 8 - headerLength;
+ final int bodyLength = length - headerLength;
Review Comment:
this line need to change:
`final int bodyLength = length - CONSTANT_MAGIC_FLAG.length - VERSION.length - headerLength;`
--
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: dev-unsubscribe@eventmesh.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: dev-help@eventmesh.apache.org