This is an automated email from the ASF dual-hosted git repository. lizhanhui pushed a commit to branch develop in repository https://gitbox.apache.org/repos/asf/rocketmq.git
The following commit(s) were added to refs/heads/develop by this push: new 327abe5d6e fix RequestCode overflowed issues:8868 (#8871) 327abe5d6e is described below commit 327abe5d6eb0b74f48867821447e2f0718509a42 Author: zzjcool <92666291+zzjc...@users.noreply.github.com> AuthorDate: Tue Oct 29 19:44:20 2024 +0800 fix RequestCode overflowed issues:8868 (#8871) Co-authored-by: zhijiezheng <zhijiezh...@tencent.com> --- .../rocketmq/remoting/protocol/RequestCode.java | 14 ++++---- .../protocol/RocketMQSerializableTest.java | 37 ++++++++++++++++++++++ 2 files changed, 44 insertions(+), 7 deletions(-) diff --git a/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RequestCode.java b/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RequestCode.java index cfc5cc2278..1e10c96f42 100644 --- a/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RequestCode.java +++ b/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RequestCode.java @@ -88,13 +88,13 @@ public class RequestCode { public static final int GET_TIMER_METRICS = 61; - public static final int POP_MESSAGE = 200050; - public static final int ACK_MESSAGE = 200051; - public static final int BATCH_ACK_MESSAGE = 200151; - public static final int PEEK_MESSAGE = 200052; - public static final int CHANGE_MESSAGE_INVISIBLETIME = 200053; - public static final int NOTIFICATION = 200054; - public static final int POLLING_INFO = 200055; + public static final short POP_MESSAGE = 3442; + public static final short ACK_MESSAGE = 3443; + public static final short BATCH_ACK_MESSAGE = 3543; + public static final short PEEK_MESSAGE = 3444; + public static final short CHANGE_MESSAGE_INVISIBLETIME = 3445; + public static final short NOTIFICATION = 3446; + public static final short POLLING_INFO = 3447; public static final int PUT_KV_CONFIG = 100; diff --git a/remoting/src/test/java/org/apache/rocketmq/remoting/protocol/RocketMQSerializableTest.java b/remoting/src/test/java/org/apache/rocketmq/remoting/protocol/RocketMQSerializableTest.java index 7cf32d70c3..c7533bd0b7 100644 --- a/remoting/src/test/java/org/apache/rocketmq/remoting/protocol/RocketMQSerializableTest.java +++ b/remoting/src/test/java/org/apache/rocketmq/remoting/protocol/RocketMQSerializableTest.java @@ -214,4 +214,41 @@ public class RocketMQSerializableTest { assertThat(h2.getStr()).isEqualTo("s1"); assertThat(h2.getNum()).isEqualTo(100); } + + @Test + public void testRequestCodeEncode() throws Exception { + testRequestCodeEncode(RequestCode.POP_MESSAGE); + testRequestCodeEncode(RequestCode.ACK_MESSAGE); + testRequestCodeEncode(RequestCode.BATCH_ACK_MESSAGE); + testRequestCodeEncode(RequestCode.PEEK_MESSAGE); + testRequestCodeEncode(RequestCode.CHANGE_MESSAGE_INVISIBLETIME); + testRequestCodeEncode(RequestCode.NOTIFICATION); + testRequestCodeEncode(RequestCode.POLLING_INFO); + } + + public void testRequestCodeEncode(int code) throws Exception { + ByteBuf buf = ByteBufAllocator.DEFAULT.buffer(16); + MyHeader1 header1 = new MyHeader1(); + header1.setStr("s1"); + header1.setNum(100); + RemotingCommand cmd = RemotingCommand.createRequestCommand(code, header1); + cmd.setRemark("remark"); + cmd.setOpaque(1001); + cmd.setVersion(99); + cmd.setLanguage(LanguageCode.JAVA); + cmd.setFlag(3); + cmd.makeCustomHeaderToNet(); + RocketMQSerializable.rocketMQProtocolEncode(cmd, buf); + RemotingCommand cmd2 = RocketMQSerializable.rocketMQProtocolDecode(buf, buf.readableBytes()); + assertThat(cmd2.getRemark()).isEqualTo("remark"); + assertThat(cmd2.getCode()).isEqualTo(code); + assertThat(cmd2.getOpaque()).isEqualTo(1001); + assertThat(cmd2.getVersion()).isEqualTo(99); + assertThat(cmd2.getLanguage()).isEqualTo(LanguageCode.JAVA); + assertThat(cmd2.getFlag()).isEqualTo(3); + + MyHeader1 h2 = (MyHeader1) cmd2.decodeCommandCustomHeader(MyHeader1.class); + assertThat(h2.getStr()).isEqualTo("s1"); + assertThat(h2.getNum()).isEqualTo(100); + } }