pandaapo commented on code in PR #4702:
URL: https://github.com/apache/eventmesh/pull/4702#discussion_r1443969068
##########
eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/tcp/codec/Codec.java:
##########
@@ -116,31 +101,45 @@ public void encode(ChannelHandlerContext ctx, Package
pkg, ByteBuf out) throws E
}
}
- public static class Decoder extends ReplayingDecoder<Package> {
+ public static class Decoder extends LengthFieldBasedFrameDecoder {
+
+ public Decoder() {
+ super(FRAME_MAX_LENGTH, 13, 4, -9, 0);
Review Comment:
My suggestion still pertains to the hardcoding of these numbers: 13, 4, -9.
To enhance code maintainability, I believe either defining two more
constants like PACKAGE_LENGTH_FIELD_LENGTH (= 4) and HEADER_LENGTH_FIELD_LENGTH
(= 4), and then entirely replacing these numbers with constants or variables,
or using comments to explain these numbers would be beneficial. I prefer the
first approach.
我的建议依然是关于数字的这种硬编码:13、4、-9。
为了让代码易于维护,我觉得要么再定义两个常量比如PACKAGE_LENGTH_FIELD_LENGTH (=
4)、HEADER_LENGTH_FIELD_LENGTH (= 4),然后完全用常量或变量来代替这些数字,要么用注释来说明这些数字。我倾向于第一种方式。
##########
eventmesh-common/src/main/java/org/apache/eventmesh/common/protocol/tcp/codec/Codec.java:
##########
@@ -161,7 +160,9 @@ private Header parseHeader(ByteBuf in, int headerLength)
throws JsonProcessingEx
}
final byte[] headerData = new byte[headerLength];
in.readBytes(headerData);
- LogUtils.debug(log, "Decode headerJson={}",
deserializeBytes(headerData));
+ if (log.isDebugEnabled()) {
Review Comment:
Regarding these modifications to the log printing, you don't have to address
them. PR #4698 is currently handling these issues uniformly.
关于日志打印的这些修改,您可以不用处理,PR #4698正在统一处理这些问题。
--
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]