diff --git a/tools/src/main/java/org/apache/rocketmq/tools/admin/DefaultMQAdminExt.java b/tools/src/main/java/org/apache/rocketmq/tools/admin/DefaultMQAdminExt.java index cab36e7d0b83d48b23b13846fbfbe484a660e4e2..af2bd715a16584f0cedc6807397a18a1e4cc005b 100644 --- a/tools/src/main/java/org/apache/rocketmq/tools/admin/DefaultMQAdminExt.java +++ b/tools/src/main/java/org/apache/rocketmq/tools/admin/DefaultMQAdminExt.java @@ -134,7 +134,7 @@ public class DefaultMQAdminExt extends ClientConfig implements MQAdminExt { return defaultMQAdminExtImpl.queryMessage(topic, key, maxNum, begin, end); } - public QueryResult queryMessageByUniqueKey(String topic, String key, int maxNum, long begin, long end) + public QueryResult queryMessageByUniqKey(String topic, String key, int maxNum, long begin, long end) throws MQClientException, InterruptedException { return defaultMQAdminExtImpl.queryMessageByUniqKey(topic, key, maxNum, begin, end); diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/message/QueryMsgByUniqueKeySubCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/message/QueryMsgByUniqueKeySubCommand.java index badac1144684d83f2bb2ae9f89250d185cf2a1fc..8c7bec616d7068a8fab2c8c03d79cabcfb1e64cb 100644 --- a/tools/src/main/java/org/apache/rocketmq/tools/command/message/QueryMsgByUniqueKeySubCommand.java +++ b/tools/src/main/java/org/apache/rocketmq/tools/command/message/QueryMsgByUniqueKeySubCommand.java @@ -62,9 +62,12 @@ public class QueryMsgByUniqueKeySubCommand implements SubCommand { final boolean showAll) throws MQClientException, RemotingException, MQBrokerException, InterruptedException, IOException { - QueryResult queryResult = admin.queryMessageByUniqueKey(topic, msgId, 32, 0, Long.MAX_VALUE); + QueryResult queryResult = admin.queryMessageByUniqKey(topic, msgId, 32, 0, Long.MAX_VALUE); assert queryResult != null; List list = queryResult.getMessageList(); + if (list == null || list.size() == 0) { + return; + } list.sort((o1, o2) -> (int) (o1.getStoreTimestamp() - o2.getStoreTimestamp())); for (int i = 0; i < (showAll ? list.size() : 1); i++) { showMessage(admin, list.get(i), i);