zjncs opened a new pull request, #11107:
URL: https://github.com/apache/rocketmq/pull/11107
## Motivation
`RebalanceImpl.doRebalance` iterates the `subscriptionInner` entry set and,
once the allocation result changes, hands the topic over to
`messageQueueChanged`. The push implementation re-reads the entry:
```java
SubscriptionData subscriptionData = this.subscriptionInner.get(topic);
long newVersion = System.currentTimeMillis();
log.info("... {} ...", ..., subscriptionData.getSubVersion(), newVersion);
subscriptionData.setSubVersion(newVersion);
```
`DefaultMQPushConsumer.unsubscribe(topic)` is a public API that runs on a
user thread and removes the entry from the same `ConcurrentHashMap`. When it
interleaves between the rebalance loop's iteration and this call,
`subscriptionInner.get(topic)` returns null and the rebalance thread dies with:
```
java.lang.NullPointerException: Cannot invoke
"SubscriptionData.getSubVersion()" because "subscriptionData" is null
```
That aborts `doRebalance` for the remaining topics of this consumer until
the next scheduled round.
## Modification
`RebalancePushImpl.messageQueueChanged`: if the subscription is already
gone, log and return — there is nothing to update or notify for a topic this
consumer no longer subscribes to.
## Test Evidence
Fail-before (unpatched develop, new regression test):
```
docker exec rmq-build mvn -q -pl client test
-Dtest='RebalancePushImplTest#testMessageQueueChanged_SubscriptionRemovedConcurrently'
Tests run: 1, Failures: 0, Errors: 1
java.lang.NullPointerException: Cannot invoke
"SubscriptionData.getSubVersion()" because "subscriptionData" is null
```
Pass-after (full class):
```
docker exec rmq-build mvn -q -pl client test -Dtest='RebalancePushImplTest'
Tests run: 8, Failures: 0, Errors: 0, Skipped: 0
```
No associated issue (self-discovered during a client-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]