Skip to content

Commit 1555042

Browse files
danpilhotari
authored andcommitted
[fix][admin] Fix exception loss in getMessageId method (#23766)
Co-authored-by: houbonan <[email protected]> (cherry picked from commit 3d50574)
1 parent cedc455 commit 1555042

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -2762,17 +2762,18 @@ protected CompletableFuture<Response> internalGetMessageById(long ledgerId, long
27622762
public void readEntryFailed(ManagedLedgerException exception,
27632763
Object ctx) {
27642764
if (exception instanceof ManagedLedgerException.LedgerNotExistException) {
2765-
throw new RestException(Status.NOT_FOUND, "Message id not found");
2765+
results.completeExceptionally(
2766+
new RestException(Status.NOT_FOUND, "Message id not found"));
27662767
}
2767-
throw new RestException(exception);
2768+
results.completeExceptionally(new RestException(exception));
27682769
}
27692770

27702771
@Override
27712772
public void readEntryComplete(Entry entry, Object ctx) {
27722773
try {
27732774
results.complete(generateResponseWithEntry(entry, (PersistentTopic) topic));
27742775
} catch (IOException exception) {
2775-
throw new RestException(exception);
2776+
results.completeExceptionally(new RestException(exception));
27762777
} finally {
27772778
if (entry != null) {
27782779
entry.release();

pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/PersistentTopicsTest.java

+4
Original file line numberDiff line numberDiff line change
@@ -1389,6 +1389,10 @@ public void testGetMessageById() throws Exception {
13891389
Assert.expectThrows(PulsarAdminException.NotFoundException.class, () -> {
13901390
admin.topics().getMessageById(topicName1, id2.getLedgerId(), id2.getEntryId());
13911391
});
1392+
1393+
Assert.expectThrows(PulsarAdminException.ServerSideErrorException.class, () -> {
1394+
admin.topics().getMessageById(topicName1, id1.getLedgerId(), id1.getEntryId() + 10);
1395+
});
13921396
}
13931397

13941398
@Test

0 commit comments

Comments
 (0)