codelipenghui commented on a change in pull request #14727:
URL: https://github.com/apache/pulsar/pull/14727#discussion_r828799516



##########
File path: 
pulsar-broker/src/main/java/org/apache/pulsar/broker/delayed/InMemoryDelayedDeliveryTracker.java
##########
@@ -78,6 +83,17 @@ public boolean addMessage(long ledgerId, long entryId, long 
deliveryAt) {
             return false;
         }
 
+        synchronized (this) {
+            if (ComparisonChain.start().compare(ledgerId, 
lastLedgerId).compare(entryId, lastEntryId).result() <= 0) {
+                if (log.isWarnEnabled()) {
+                    log.warn("[{}] Add message  {}:{}  less than last {} {} ", 
dispatcher.getName(), ledgerId, entryId,

Review comment:
       The info log is ok here since it's expected behavior.

##########
File path: 
pulsar-broker/src/main/java/org/apache/pulsar/broker/delayed/InMemoryDelayedDeliveryTracker.java
##########
@@ -78,6 +83,17 @@ public boolean addMessage(long ledgerId, long entryId, long 
deliveryAt) {
             return false;
         }
 
+        synchronized (this) {

Review comment:
       I think we don't need `synchronized` here?
   
   The `InMemoryDelayedDeliveryTracker` is not a thread-safe container.

##########
File path: 
pulsar-broker/src/main/java/org/apache/pulsar/broker/delayed/InMemoryDelayedDeliveryTracker.java
##########
@@ -78,6 +83,17 @@ public boolean addMessage(long ledgerId, long entryId, long 
deliveryAt) {
             return false;
         }
 
+        synchronized (this) {
+            if (ComparisonChain.start().compare(ledgerId, 
lastLedgerId).compare(entryId, lastEntryId).result() <= 0) {

Review comment:
       Using Guava's ComparisonChain will create object instances.
   
   ```java
   if (ledgerId < lastLedgerId || (ledgerId == lastLedgerId && entryId < 
lastEntryId))
   ```




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