zjncs opened a new pull request, #11110:
URL: https://github.com/apache/rocketmq/pull/11110

   ## Motivation
   
   `Broker2Client.getConsumeStatus` dereferences the consumer group info before 
checking it:
   
   ```java
   ConcurrentMap<Channel, ClientChannelInfo> channelInfoTable =
       
this.brokerController.getConsumerManager().getConsumerGroupInfo(group).getChannelInfoTable();
   if (null == channelInfoTable || channelInfoTable.isEmpty()) {
       // "No Any Consumer online in the consumer group: [%s]"
   }
   ```
   
   When the queried group has no consumer registered on this broker — the 
normal situation for an offline group — `getConsumerGroupInfo(group)` returns 
null and the method throws `NullPointerException` before reaching the error 
branch that was written for exactly this case. The sibling `resetOffset` method 
checks the group info for null first.
   
   Reached from `mqadmin getConsumerStatus` 
(`INVOKE_BROKER_TO_GET_CONSUMER_STATUS` → 
`AdminBrokerProcessor.getConsumerStatus` → here), the NPE surfaces to the admin 
as a bare SYSTEM_ERROR with a null-pointer remark instead of the intended 
message.
   
   ## Modification
   
   Fetch the `ConsumerGroupInfo` first; enter the existing "No Any Consumer 
online" branch when it is null or its channel table is empty; read the channel 
table only afterwards.
   
   ## Test Evidence
   
   Fail-before (unpatched develop, new regression test):
   
   ```
   mvn -q -pl broker test 
-Dtest='Broker2ClientTest#testGetConsumeStatusGroupNotRegistered'
   Tests run: 1, Errors: 1 - NullPointerException: Cannot invoke 
"ConsumerGroupInfo.getChannelInfoTable()"
   ```
   
   Pass-after (full class):
   
   ```
   mvn -q -pl broker test -Dtest='Broker2ClientTest'
   Tests run: 9, Failures: 0, Errors: 0, Skipped: 0
   ```
   
   No associated issue (self-discovered during a broker-module self-audit).


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