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

   ## Summary
   
   Refactor `MQClientInstance.registerConsumer()` to throw `MQClientException` 
directly when a duplicate consumer group is detected, instead of returning 
`false` and requiring every caller to check and throw separately.
   
   ## Before
   ```java
   // MQClientInstance
   public synchronized boolean registerConsumer(group, consumer) {
       if (prev != null) {
           log.warn("exist already.");
           return false;  // caller must check
       }
       return true;
   }
   
   // Every caller duplicated this:
   boolean registerOK = mQClientFactory.registerConsumer(group, this);
   if (!registerOK) {
       throw new MQClientException("...created before...");
   }
   ```
   
   ## After
   ```java
   // MQClientInstance
   public synchronized void registerConsumer(group, consumer) throws 
MQClientException {
       if (prev != null) {
           throw new MQClientException("...created before...");
       }
   }
   
   // Callers are clean:
   
mQClientFactory.registerConsumer(this.defaultMQPushConsumer.getConsumerGroup(), 
this);
   ```
   
   ## Files Changed
   - `MQClientInstance.java` - throw exception instead of returning false
   - `DefaultMQPushConsumerImpl.java` - remove redundant check
   - `DefaultMQPullConsumerImpl.java` - remove redundant check
   - `DefaultLitePullConsumerImpl.java` - remove redundant check


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