dragon-zhang commented on a change in pull request #2983:
URL: https://github.com/apache/rocketmq/pull/2983#discussion_r730397064



##########
File path: 
client/src/main/java/org/apache/rocketmq/client/impl/consumer/ConsumeMessageStagedConcurrentlyService.java
##########
@@ -179,15 +179,20 @@ public AtomicInteger getCurrentStageOffset(MessageQueue 
messageQueue, String top
         if (null == groupByStrategy) {
             ConcurrentMap<String, ConcurrentMap<String, AtomicInteger>> 
stageOffset = stageOffsetStore == null ?
                 new ConcurrentHashMap<>() : 
convert(stageOffsetStore.readStageOffset(messageQueue, 
ReadOffsetType.MEMORY_FIRST_THEN_STORE));
-            currentStageOffsetMap.putIfAbsent(topic, stageOffset);
+            currentStageOffsetMap.put(topic, stageOffset);
             groupByStrategy = currentStageOffsetMap.get(topic);
         }
-        ConcurrentMap<String, AtomicInteger> groups = 
groupByStrategy.putIfAbsent(strategyId, new ConcurrentHashMap<>());
+        ConcurrentMap<String, AtomicInteger> groups = 
groupByStrategy.get(strategyId);
         if (null == groups) {
+            groupByStrategy.put(strategyId, new ConcurrentHashMap<>());

Review comment:
       ```java
       public AtomicInteger getCurrentStageOffset(MessageQueue messageQueue, 
String topic, String strategyId,
           String groupId) {
           if (null == strategyId || NULL.equals(strategyId)) {
               return new AtomicInteger(-1);
           }
           groupId = String.valueOf(groupId);
           ConcurrentMap<String, ConcurrentMap<String, AtomicInteger>> 
groupByStrategy = currentStageOffsetMap.computeIfAbsent(topic,
               key -> (stageOffsetStore == null ? new ConcurrentHashMap<>() : 
convert(stageOffsetStore.readStageOffset(messageQueue, 
ReadOffsetType.MEMORY_FIRST_THEN_STORE)))
           );
           ConcurrentMap<String, AtomicInteger> groups = 
groupByStrategy.computeIfAbsent(strategyId, key -> new ConcurrentHashMap<>());
           return groups.computeIfAbsent(groupId, key -> new AtomicInteger(0));
       }
   ```
   How about this one ?




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