yx9o commented on code in PR #10283:
URL: https://github.com/apache/rocketmq/pull/10283#discussion_r3169241667
##########
remoting/src/test/java/org/apache/rocketmq/remoting/protocol/RemotingSerializableTest.java:
##########
@@ -121,6 +123,22 @@ public Map<Long, String> getMap() {
Assert.fail("Should not throw");
}
}
+ @Test
+ public void testDecodeUnquotedFieldNames() {
+ // 模拟 5.4.x 版本序列化的 consumerOffset 格式(数字 key 无引号)
+ String jsonWithUnquotedKeys =
"{\"offsetTable\":{\"TopicTest@gid-test\":{0:123,1:456}}}";
+ Map<String, Map<Integer, Long>> result =
RemotingSerializable.fromJson(jsonWithUnquotedKeys, Map.class);
+ assertNotNull(result);
+ Map offsetTable = (Map) result.get("offsetTable");
+ assertNotNull(offsetTable);
+
+ Map topicOffsets = (Map) offsetTable.get("TopicTest@gid-test");
+ assertNotNull(topicOffsets);
+
+ assertEquals(123L, ((Number) topicOffsets.get("0")).longValue());
Review Comment:
Could you clarify why get("0") is used here? consumerOffset uses Integer
queueId keys, and get(0) works.
--
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]