BewareMyPower commented on code in PR #21187:
URL: https://github.com/apache/pulsar/pull/21187#discussion_r1455325323


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/Consumer.java:
##########
@@ -443,6 +445,10 @@ public CompletableFuture<Void> messageAcked(CommandAck 
ack) {
             properties = ack.getPropertiesList().stream()
                 .collect(Collectors.toMap(KeyLongValue::getKey, 
KeyLongValue::getValue));
         }
+        if (readCompacted) {
+            properties = new TreeMap<>(properties);
+            properties.put(READ_COMPACTED_CURSOR_PROPERTIES, 1L);
+        }

Review Comment:
   It's meaningless to use a TreeMap here.
   
   ```suggestion
           if (readCompacted) {
               properties = 
Collections.singletonMap(ManagedCursorImpl.READ_COMPACTED_CURSOR_PROPERTIES, 
1L);
           }
   ```



##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentTopic.java:
##########
@@ -1017,6 +1021,10 @@ private CompletableFuture<Subscription> 
getDurableSubscription(String subscripti
         }
 
         Map<String, Long> properties = 
PersistentSubscription.getBaseCursorProperties(replicated);
+        if (readCompacted) {
+            properties = new TreeMap<>(properties);
+            properties.put(READ_COMPACTED_CURSOR_PROPERTIES, 1L);

Review Comment:
   Why did you create a new map instead of modifying the `properties`? (the 
same question as it is in `readMoreEntries`)
   
   ```java
           if (readCompacted) {
               properties = new HashMap<>(properties);
               properties.put(READ_COMPACTED_CURSOR_PROPERTIES, 1L);
           }
   ```
   
   



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