Skip to content

Commit

Permalink
Fix get-message-by-id throwing NPE when message is null (apache#9537)
Browse files Browse the repository at this point in the history
Fixes apache#9518

### Modifications
Add friendly reminder tips for command
  • Loading branch information
315157973 authored Feb 15, 2021
1 parent 9c2b081 commit 6ebc795
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -835,6 +835,9 @@ public void topics() throws Exception {
cmdTopics.run(split("set-max-message-size persistent://myprop/clust/ns1/ds1 -m 99"));
verify(mockTopics).setMaxMessageSize("persistent://myprop/clust/ns1/ds1", 99);

cmdTopics.run(split("get-message-by-id persistent://myprop/clust/ns1/ds1 -l 10 -e 2"));
verify(mockTopics).getMessageById("persistent://myprop/clust/ns1/ds1", 10,2);

cmdTopics.run(split("get-retention persistent://myprop/clust/ns1/ds1"));
verify(mockTopics).getRetention("persistent://myprop/clust/ns1/ds1", false);
cmdTopics.run(split("set-retention persistent://myprop/clust/ns1/ds1 -t 10m -s 20M"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -889,9 +889,13 @@ void run() throws PulsarAdminException {
String persistentTopic = validatePersistentTopic(params);

Message<byte[]> message = getTopics().getMessageById(persistentTopic, ledgerId, entryId);

ByteBuf date = Unpooled.wrappedBuffer(message.getData());
System.out.println(ByteBufUtil.prettyHexDump(date));
if (message == null) {
System.out.println("Cannot find any messages based on ledgerId:"
+ ledgerId + " entryId:" + entryId);
} else {
ByteBuf date = Unpooled.wrappedBuffer(message.getData());
System.out.println(ByteBufUtil.prettyHexDump(date));
}
}
}

Expand Down

0 comments on commit 6ebc795

Please sign in to comment.