This is an automated email from the ASF dual-hosted git repository. jimin pushed a commit to branch 2.x in repository https://gitbox.apache.org/repos/asf/incubator-seata.git
The following commit(s) were added to refs/heads/2.x by this push: new 108240fb2b optimize : compatible for client_protocol_version > server_protocol_version (#7250) 108240fb2b is described below commit 108240fb2b13fad406037fe094dc4a8d777994e7 Author: justabug <bug...@users.noreply.github.com> AuthorDate: Wed Apr 2 17:49:11 2025 +0800 optimize : compatible for client_protocol_version > server_protocol_version (#7250) --- changes/en-us/2.x.md | 3 +++ changes/zh-cn/2.x.md | 2 ++ .../seata/core/rpc/netty/MultiProtocolDecoder.java | 22 +++++++++++++++------- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/changes/en-us/2.x.md b/changes/en-us/2.x.md index 507c5e23fe..28563be795 100644 --- a/changes/en-us/2.x.md +++ b/changes/en-us/2.x.md @@ -75,6 +75,9 @@ Add changes here for all PR submitted to the 2.x branch. - [[#7222](https://github.com/apache/incubator-seata/pull/7222)] in raft mode add the vgroup field to global lock - [[#7229](https://github.com/apache/incubator-seata/pull/7229)] update Notice - [[#7234](https://github.com/apache/incubator-seata/pull/7234)] discover the raft leader node from the naming server +- [[#7242](https://github.com/apache/incubator-seata/pull/7242)] optimize: optimize ratelimit bucketTokenNumPerSecond config +- [[#6998](https://github.com/apache/incubator-seata/pull/6998)] skip sending some request if client-version is v0 +- [[#7250](https://github.com/apache/incubator-seata/pull/7250)] compatible for client_protocol_version > server_protocol_version - [[#7242](https://github.com/apache/incubator-seata/pull/7242)] optimize ratelimit bucketTokenNumPerSecond config - [[#7232](https://github.com/apache/incubator-seata/pull/7232)] add license header - [[#7260](https://github.com/apache/incubator-seata/pull/7260)] upgrade npmjs dependencies diff --git a/changes/zh-cn/2.x.md b/changes/zh-cn/2.x.md index 25cba7f377..51939ed8f6 100644 --- a/changes/zh-cn/2.x.md +++ b/changes/zh-cn/2.x.md @@ -76,6 +76,8 @@ - [[#7229](https://github.com/apache/incubator-seata/pull/7229)] 更新 Notice - [[#7234](https://github.com/apache/incubator-seata/pull/7234)] 优化raft对接namingserve时的服务发现逻辑 - [[#7242](https://github.com/apache/incubator-seata/pull/7242)] 更改参考案例下的ratelimit配置 +- [[#6998](https://github.com/apache/incubator-seata/pull/6998)] 跳过协议版本v0不支持的request +- [[#7250](https://github.com/apache/incubator-seata/pull/7250)] 适配 client_protocol_version > server_protocol_version场景 - [[#7232](https://github.com/apache/incubator-seata/pull/7232)] 增加 license header - [[#7260](https://github.com/apache/incubator-seata/pull/7260)] 升级 npmjs 依赖版本 diff --git a/core/src/main/java/org/apache/seata/core/rpc/netty/MultiProtocolDecoder.java b/core/src/main/java/org/apache/seata/core/rpc/netty/MultiProtocolDecoder.java index 9bd9550369..9d284509a9 100644 --- a/core/src/main/java/org/apache/seata/core/rpc/netty/MultiProtocolDecoder.java +++ b/core/src/main/java/org/apache/seata/core/rpc/netty/MultiProtocolDecoder.java @@ -61,7 +61,7 @@ public class MultiProtocolDecoder extends LengthFieldBasedFrameDecoder { private final Map<Byte, ProtocolDecoder> protocolDecoderMap; private final Map<Byte, ProtocolEncoder> protocolEncoderMap; - + private final ChannelHandler[] channelHandlers; public MultiProtocolDecoder(ChannelHandler... channelHandlers) { @@ -84,11 +84,11 @@ public class MultiProtocolDecoder extends LengthFieldBasedFrameDecoder { */ super(maxFrameLength, 3, 4, -7, 0); this.protocolDecoderMap = - ImmutableMap.<Byte, ProtocolDecoder>builder().put(ProtocolConstants.VERSION_0, new ProtocolDecoderV0()) - .put(ProtocolConstants.VERSION_1, new ProtocolDecoderV1()).build(); + ImmutableMap.<Byte, ProtocolDecoder>builder().put(ProtocolConstants.VERSION_0, new ProtocolDecoderV0()) + .put(ProtocolConstants.VERSION_1, new ProtocolDecoderV1()).build(); this.protocolEncoderMap = - ImmutableMap.<Byte, ProtocolEncoder>builder().put(ProtocolConstants.VERSION_0, new ProtocolEncoderV0()) - .put(ProtocolConstants.VERSION_1, new ProtocolEncoderV1()).build(); + ImmutableMap.<Byte, ProtocolEncoder>builder().put(ProtocolConstants.VERSION_0, new ProtocolEncoderV0()) + .put(ProtocolConstants.VERSION_1, new ProtocolEncoderV1()).build(); this.channelHandlers = channelHandlers; } @@ -109,7 +109,15 @@ public class MultiProtocolDecoder extends LengthFieldBasedFrameDecoder { if (decoded instanceof ByteBuf) { frame = (ByteBuf) decoded; ProtocolDecoder decoder = protocolDecoderMap.get(version); + if (decoder == null) { + LOGGER.error("Decoder not found, version={}, use current version({})", version,ProtocolConstants.VERSION); + decoder = protocolDecoderMap.get(ProtocolConstants.VERSION); + } ProtocolEncoder encoder = protocolEncoderMap.get(version); + if (encoder == null) { + LOGGER.error("Encoder not found, version: {}, use current version({})", version,ProtocolConstants.VERSION); + encoder = protocolEncoderMap.get(ProtocolConstants.VERSION); + } try { if (decoder == null || encoder == null) { throw new UnsupportedOperationException("Unsupported version: " + version); @@ -119,8 +127,8 @@ public class MultiProtocolDecoder extends LengthFieldBasedFrameDecoder { if (version != ProtocolConstants.VERSION_0) { frame.release(); } - ctx.pipeline().addLast((ChannelHandler)decoder); - ctx.pipeline().addLast((ChannelHandler)encoder); + ctx.pipeline().addLast((ChannelHandler) decoder); + ctx.pipeline().addLast((ChannelHandler) encoder); if (channelHandlers != null) { ctx.pipeline().addLast(channelHandlers); } --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@seata.apache.org For additional commands, e-mail: notifications-h...@seata.apache.org