3pacccccc opened a new pull request, #25036:
URL: https://github.com/apache/pulsar/pull/25036

   ### Motivation
   Currently, several methods in the ```MessageAcknowledger``` interface 
implementation do not validate null parameters for messages, message IDs, or 
message lists. Passing null values to methods such as 
```acknowledge(List<MessageId>)```, ```acknowledge(Messages)```, or 
```acknowledgeAsync(MessageId, Transaction)``` can lead to unexpected 
```NullPointerException``` errors deep in the call stack. This PR adds explicit 
null validation at the entry points of these methods to provide clear, early 
feedback to developers.
   ### Modifications
   1. Added ```validateMessageIds(List<MessageId>)``` and 
```validateMessages(Messages)``` helper methods in ```ConsumerBase.java``` to 
check for null inputs and throw a descriptive 
```PulsarClientException.InvalidMessageException```.
   
   2. Integrated these validation checks into:
   
   - ```acknowledge(List<MessageId>)```
   
   - ```acknowledge(Messages)```
   
   - ```acknowledgeAsync(MessageId, Transaction)```
   
   - ```acknowledgeCumulativeAsync(MessageId, Transaction)```
   
   - ```doAcknowledgeWithTxn(...)```
   
   3. Added corresponding unit tests in multiple test classes to verify that 
null inputs are properly rejected with appropriate exception messages:
   
   - ```TransactionTest.testAckTnxWithNullMessageId()```
   
   - ```ConsumerAckListTest.testAckNullMessageIdList()```
   
   - ```ConsumerBatchReceiveTest.testBatchReceiveAckWithNullMessages()```
   
   - 
```TransactionEndToEndTest.testAcknowledgeCumulativeAsyncWithNullMessageId()```
   ### Verifying this change
   
   - [x] Make sure that the change passes the CI checks.
   
   
   <!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
   
   ### Documentation
   
   <!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
   
   - [ ] `doc` <!-- Your PR contains doc changes. -->
   - [x] `doc-required` <!-- Your PR changes impact docs and you will update 
later -->
   - [ ] `doc-not-needed` <!-- Your PR changes do not impact docs -->
   - [ ] `doc-complete` <!-- Docs have been already added -->
   
   ### Matching PR in forked repository
   
   PR in forked repository: https://github.com/3pacccccc/pulsar/pull/31
   
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to