yin-bo-Final opened a new issue, #10419:
URL: https://github.com/apache/rocketmq/issues/10419

   ### Before Creating the Bug Report
   
   - [x] I found a bug, not just asking a question, which should be created in 
[GitHub Discussions](https://github.com/apache/rocketmq/discussions).
   
   - [x] I have searched the [GitHub 
Issues](https://github.com/apache/rocketmq/issues) and [GitHub 
Discussions](https://github.com/apache/rocketmq/discussions)  of this 
repository and believe that this is not a duplicate.
   
   - [x] I have confirmed that this bug belongs to the current repository, not 
other repositories of RocketMQ.
   
   
   ### Runtime platform environment
   
   ubuntu
   
   ### RocketMQ version
   
   develop branch / rocketmq-all-5.5.0
   
   ### JDK Version
   
   JDK 8
   
   ### Describe the Bug
   
   When a consumer pulls messages with class filter enabled, 
`PullAPIWrapper#computePullFromWhichFilterServer` may throw a 
`NullPointerException` if the local topic route table does not contain route 
data for the target topic.
   
   The current code directly dereferences `topicRouteData`:
   
   ```java
   TopicRouteData topicRouteData = topicRouteTable.get(topic);
   List<String> list = topicRouteData.getFilterServerTable().get(brokerAddr);
   If topicRouteData is null, the client throws NPE before reaching the 
existing business error path.
   
   The method already has a clear fallback exception when no filter server can 
be found:
   
   throw new MQClientException("Find Filter Server Failed, Broker Addr: " + 
brokerAddr + " topic: " + topic, null);
   So the client should fail with MQClientException instead of exposing a raw 
NPE.
   
   ### Steps to Reproduce
   
   1. Create a PullAPIWrapper.
   2. Enable class filter in the pull sys flag.
   3. Mock or configure MQClientInstance#getTopicRouteTable() to return a route 
table that does not contain the target topic, or contains a TopicRouteData 
without a filter server mapping for the broker address.
   4. Call PullAPIWrapper#pullKernelImpl.
   5. The call enters computePullFromWhichFilterServer and throws 
NullPointerException.
   
   ### What Did You Expect to See?
   
   The client should fail gracefully with MQClientException, for example:  
`Find Filter Server Failed, Broker Addr: xxx topic: xxx`
   This is consistent with the existing method behavior when no filter server 
is found.
   
   ### What Did You See Instead?
   
   The client may throw NullPointerException from 
PullAPIWrapper#computePullFromWhichFilterServer before reaching the intended 
MQClientException branch.
   
   ### Additional Context
   
   This problem is caused by method:
   
`org.apache.rocketmq.client.impl.consumer.PullAPIWrapper#computePullFromWhichFilterServer`
   The method currently assumes that topicRouteData is always available before 
accessing its filter server table. When the route data is missing, it may be 
better to fall through to the existing MQClientException path instead of 
throwing NPE.
   


-- 
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