Skip to content

Commit

Permalink
fix old version decode
Browse files Browse the repository at this point in the history
  • Loading branch information
Bughue committed Jul 24, 2024
1 parent fb04957 commit 8ba49a0
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
1 change: 1 addition & 0 deletions changes/en-us/2.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ Add changes here for all PR submitted to the 2.x branch.
### test:
- [[#6608](https://github.com/apache/incubator-seata/pull/6608)] add unit test for sql-parser-core
- [[#6647](https://github.com/apache/incubator-seata/pull/6647)] improve the test case coverage of saga module to 70%
- [[#6695](https://github.com/apache/incubator-seata/pull/6695)] old version(< 0.7.1) client test case for multi-version protocol


Thanks to these contributors for their code commits. Please report an unintended omission.
Expand Down
1 change: 1 addition & 0 deletions changes/zh-cn/2.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
### test:
- [[#6608](https://github.com/apache/incubator-seata/pull/6608)] 添加sql-parser-core模块测试用例
- [[#6647](https://github.com/apache/incubator-seata/pull/6647)] 增加saga模块的测试用例覆盖率
- [[#6695](https://github.com/apache/incubator-seata/pull/6647)] 多版本协议的旧版本(< 0.7.1)客户端测试用例



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ public static String getChannelVersion(Channel c) {
public static void checkVersion(String version) throws IncompatibleVersionException {
long current = convertVersion(CURRENT);
long clientVersion = convertVersion(version);
if (current < clientVersion) {
long divideVersion = convertVersion(VERSION_0_7_1);
if ((current > divideVersion && clientVersion < divideVersion) || (current < divideVersion && clientVersion > divideVersion)) {
throw new IncompatibleVersionException("incompatible client version:" + version);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,15 +144,22 @@ public RpcMessage decodeFrame(ByteBuf in) {

@Override
protected Object decode(ChannelHandlerContext ctx, ByteBuf in) throws Exception {
Object decoded;
try {
if (in instanceof ByteBuf) {
return decodeFrame(in);
decoded = super.decode(ctx, in);
if (decoded instanceof ByteBuf) {
ByteBuf frame = (ByteBuf)decoded;
try {
return decodeFrame(frame);
} finally {
frame.release();
}
}
} catch (Exception exx) {
LOGGER.error("Decode frame error, cause: {}", exx.getMessage());
throw new DecodeException(exx);
}
return in;
return decoded;
}

}

0 comments on commit 8ba49a0

Please sign in to comment.