You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by "ZhaoGuorui666 (via GitHub)" <gi...@apache.org> on 2024/11/06 13:24:50 UTC
[PR] [improve][consumer] Optimizing Exception Handling and Logging in `MultiTopicsConsumerImpl` [pulsar]
ZhaoGuorui666 opened a new pull request, #23568:
URL: https://github.com/apache/pulsar/pull/23568
### Motivation
1. **Generic Exception Handling**:
- The `internalReceive` method currently catches all exceptions, which can obscure the root cause of specific failures, such as invalid message types.
2. **Insufficient Logging for Validation Failures**:
- When `Preconditions.checkArgument` fails (throwing an `IllegalArgumentException`), the existing implementation does not log detailed information about the failure. This limitation makes it challenging to diagnose issues related to message type mismatches.
### Modifications
- **Enhanced Exception Handling**: Added a specific `catch` block for `IllegalArgumentException` to log detailed information before rethrowing as a `PulsarClientException`.
### Verifying this change
### Documentation
<!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
- [ ] `doc` <!-- Your PR contains doc changes. -->
- [ ] `doc-required` <!-- Your PR changes impact docs and you will update later -->
- [x] `doc-not-needed` <!-- Your PR changes do not impact docs -->
- [ ] `doc-complete` <!-- Docs have been already added -->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [improve][consumer] Optimizing Exception Handling and Logging in `MultiTopicsConsumerImpl` [pulsar]
Posted by "merlimat (via GitHub)" <gi...@apache.org>.
merlimat closed pull request #23568: [improve][consumer] Optimizing Exception Handling and Logging in `MultiTopicsConsumerImpl`
URL: https://github.com/apache/pulsar/pull/23568
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [improve][consumer] Optimizing Exception Handling and Logging in `MultiTopicsConsumerImpl` [pulsar]
Posted by "merlimat (via GitHub)" <gi...@apache.org>.
merlimat commented on PR #23568:
URL: https://github.com/apache/pulsar/pull/23568#issuecomment-6182230476
Hi @Ronnie-Rui, thanks for the contribution, and sorry it never got a proper review. The question in the review about when this case can actually happen was left open, and the change hasn't found users asking for it. The client code around it has also changed a lot since, including the move to Gradle and to slog for logging, so it would need a fresh start. We're going through the backlog of open PRs (https://lists.apache.org/thread/cgy7w0qgnq8s7j0ykyzgrn3hj4nb67wf), so I'm closing this one. If you hit a case where this happens, feel free to open an issue with the details.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [improve][consumer] Optimizing Exception Handling and Logging in `MultiTopicsConsumerImpl` [pulsar]
Posted by "nodece (via GitHub)" <gi...@apache.org>.
nodece commented on code in PR #23568:
URL: https://github.com/apache/pulsar/pull/23568#discussion_r1832898293
##########
pulsar-client/src/main/java/org/apache/pulsar/client/impl/MultiTopicsConsumerImpl.java:
##########
@@ -383,6 +383,12 @@ protected Message<T> internalReceive() throws PulsarClientException {
unAckedMessageTracker.add(message.getMessageId(), message.getRedeliveryCount());
resumeReceivingFromPausedConsumersIfNeeded();
return beforeConsume(message);
+ } catch (IllegalArgumentException e) {
Review Comment:
It looks `checkState(message instanceof TopicMessageImpl);` will throw this exception.
When will this happen? Could you shared your case?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org