You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by lh...@apache.org on 2024/12/21 16:55:23 UTC

(pulsar) branch branch-3.0 updated: [fix][admin] Fix exception loss in getMessageId method (#23766)

This is an automated email from the ASF dual-hosted git repository.

lhotari pushed a commit to branch branch-3.0
in repository https://gitbox.apache.org/repos/asf/pulsar.git


The following commit(s) were added to refs/heads/branch-3.0 by this push:
     new 79e05a2d1d2 [fix][admin] Fix exception loss in getMessageId method (#23766)
79e05a2d1d2 is described below

commit 79e05a2d1d2430c7c67e1e53e5ff55407f8d6351
Author: danpi <da...@gmail.com>
AuthorDate: Sat Dec 21 19:20:56 2024 +0800

    [fix][admin] Fix exception loss in getMessageId method (#23766)
    
    Co-authored-by: houbonan <ho...@didiglobal.com>
    (cherry picked from commit 3d505742e05e403144d17aef59c95e2758982a26)
---
 .../org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java  | 7 ++++---
 .../java/org/apache/pulsar/broker/admin/PersistentTopicsTest.java  | 4 ++++
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java
index 62335cebc4a..aadd9bc18af 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java
@@ -2971,9 +2971,10 @@ public class PersistentTopicsBase extends AdminResource {
                         public void readEntryFailed(ManagedLedgerException exception,
                                                     Object ctx) {
                             if (exception instanceof ManagedLedgerException.LedgerNotExistException) {
-                                throw new RestException(Status.NOT_FOUND, "Message id not found");
+                                results.completeExceptionally(
+                                        new RestException(Status.NOT_FOUND, "Message id not found"));
                             }
-                            throw new RestException(exception);
+                            results.completeExceptionally(new RestException(exception));
                         }
 
                         @Override
@@ -2981,7 +2982,7 @@ public class PersistentTopicsBase extends AdminResource {
                             try {
                                 results.complete(generateResponseWithEntry(entry, (PersistentTopic) topic));
                             } catch (IOException exception) {
-                                throw new RestException(exception);
+                                results.completeExceptionally(new RestException(exception));
                             } finally {
                                 if (entry != null) {
                                     entry.release();
diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/PersistentTopicsTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/PersistentTopicsTest.java
index f453d573acd..a5063802cfe 100644
--- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/PersistentTopicsTest.java
+++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/PersistentTopicsTest.java
@@ -1380,6 +1380,10 @@ public class PersistentTopicsTest extends MockedPulsarServiceBaseTest {
         Assert.expectThrows(PulsarAdminException.NotFoundException.class, () -> {
             admin.topics().getMessageById(topicName1, id2.getLedgerId(), id2.getEntryId());
         });
+
+        Assert.expectThrows(PulsarAdminException.ServerSideErrorException.class, () -> {
+            admin.topics().getMessageById(topicName1, id1.getLedgerId(), id1.getEntryId() + 10);
+        });
     }
 
     @Test