apupier commented on code in PR #26775:
URL: https://github.com/apache/camel/pull/26775#discussion_r4083707912


##########
core/camel-core-processor/src/main/java/org/apache/camel/processor/TotalRequestsThrottler.java:
##########
@@ -184,7 +184,11 @@ protected boolean processAsynchronously(
                 exchange.setProperty(PROPERTY_EXCHANGE_QUEUED_TIMESTAMP, 
System.nanoTime());
             }
             exchange.setProperty(PROPERTY_EXCHANGE_STATE, State.ASYNC);
-            long delay = throttlingState.peek().getDelay(TimeUnit.NANOSECONDS);
+            ThrottlePermit next = throttlingState.peek();
+            // there is no permit in the queue when the rate is 0, or when the 
only permits are taken by other
+            // exchanges and not yet returned, so try again after one period
+            long delay = next != null
+                    ? next.getDelay(TimeUnit.NANOSECONDS) : 
TimeUnit.MILLISECONDS.toNanos(getTimePeriodMillis());

Review Comment:
   Is it possible that there is still no permit available after the amount of 
time?
   Shouldn't it be still await longer in this case?



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