mattisonchao commented on a change in pull request #13993:
URL: https://github.com/apache/pulsar/pull/13993#discussion_r794094031



##########
File path: 
pulsar-client/src/main/java/org/apache/pulsar/client/impl/Backoff.java
##########
@@ -84,19 +121,30 @@ public long next() {
         return Math.max(initial, current);
     }
 
-    public void reduceToHalf() {
+    /**
+     * Reduce the next backoff to half of its current value. If the result is 
less than {@link #initial}, set
+     * {@link #next} to {@link #initial}.
+     */
+    public synchronized void reduceToHalf() {
         if (next > initial) {
             this.next = Math.max(this.next / 2, this.initial);
         }
     }
 
-    public void reset() {
+    /**
+     * Reset this {@link Backoff} instance to its initial state.
+     */
+    public synchronized void reset() {
         this.next = this.initial;
         this.mandatoryStopMade = false;
     }
 
+    public synchronized boolean isMandatoryStopMade() {
+        return mandatoryStopMade;
+    }
+
     @VisibleForTesting
-    long getFirstBackoffTimeInMillis() {
+    synchronized long getFirstBackoffTimeInMillis() {

Review comment:
       same above. 👆 

##########
File path: 
pulsar-client/src/main/java/org/apache/pulsar/client/impl/Backoff.java
##########
@@ -84,19 +121,30 @@ public long next() {
         return Math.max(initial, current);
     }
 
-    public void reduceToHalf() {
+    /**
+     * Reduce the next backoff to half of its current value. If the result is 
less than {@link #initial}, set
+     * {@link #next} to {@link #initial}.
+     */
+    public synchronized void reduceToHalf() {
         if (next > initial) {
             this.next = Math.max(this.next / 2, this.initial);
         }
     }
 
-    public void reset() {
+    /**
+     * Reset this {@link Backoff} instance to its initial state.
+     */
+    public synchronized void reset() {
         this.next = this.initial;
         this.mandatoryStopMade = false;
     }
 
+    public synchronized boolean isMandatoryStopMade() {

Review comment:
       This method looks like just getting the current value, should we 
synchronize it?




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