Skip to content

Commit

Permalink
[improve][client] Enhance error handling for non-exist subscription i…
Browse files Browse the repository at this point in the history
…n consumer creation (apache#23254)
  • Loading branch information
Shawyeok authored Nov 29, 2024
1 parent bf1f677 commit 7fc88d6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -413,8 +413,9 @@ public void testSubscriptionNotFound() throws PulsarAdminException, PulsarClient
.isAckReceiptEnabled(true)
.subscribe();
assertTrue(singleTopicConsumer instanceof ConsumerImpl);
} catch (PulsarClientException.SubscriptionNotFoundException ignore) {
} catch (Throwable t) {
assertTrue(t.getCause().getCause() instanceof PulsarClientException.SubscriptionNotFoundException);
fail("Should throw PulsarClientException.SubscriptionNotFoundException instead");
}

try {
Expand All @@ -424,8 +425,9 @@ public void testSubscriptionNotFound() throws PulsarAdminException, PulsarClient
.isAckReceiptEnabled(true)
.subscribe();
assertTrue(multiTopicsConsumer instanceof MultiTopicsConsumerImpl);
} catch (PulsarClientException.SubscriptionNotFoundException ignore) {
} catch (Throwable t) {
assertTrue(t.getCause().getCause() instanceof PulsarClientException.SubscriptionNotFoundException);
fail("Should throw PulsarClientException.SubscriptionNotFoundException instead");
}

pulsar.getConfiguration().setAllowAutoSubscriptionCreation(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1113,6 +1113,8 @@ public static PulsarClientException unwrap(Throwable t) {
newException = new TransactionConflictException(msg);
} else if (cause instanceof TopicDoesNotExistException) {
newException = new TopicDoesNotExistException(msg);
} else if (cause instanceof SubscriptionNotFoundException) {
newException = new SubscriptionNotFoundException(msg);
} else if (cause instanceof ProducerFencedException) {
newException = new ProducerFencedException(msg);
} else if (cause instanceof MemoryBufferIsFullError) {
Expand Down

0 comments on commit 7fc88d6

Please sign in to comment.