Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[improve][client] Enhance error handling for non-exist subscription in consumer creation #23254

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -1144,6 +1144,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
Loading