Skip to content

Commit

Permalink
Fix max stored permits
Browse files Browse the repository at this point in the history
  • Loading branch information
hexiaofeng committed Jan 23, 2025
1 parent 8d202af commit f7328fc
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public LeakyBucketLimiter(RateLimitPolicy limitPolicy, SlidingWindow slidingWind
@Override
protected double getMaxStoredPermits() {
// Keep a constant rate and prevent excessive token accumulation.
return Math.max(getPermits(option.getPositive(KEY_FLOW_WINDOW_SECONDS, 1)), 1D);
return getPermits(option.getPositive(KEY_FLOW_WINDOW_SECONDS, 1));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ protected boolean doAcquire(int permits, long nowMicros, long timeoutMicros) {
* Initializes the rate limiter by setting the maximum number of permits.
*/
protected void initialize() {
this.maxStoredPermits = getMaxStoredPermits();
this.maxStoredPermits = Math.max(getMaxStoredPermits(), 1D);
}

/**
Expand Down

0 comments on commit f7328fc

Please sign in to comment.