Skip to content

Commit 5d4eeb4

Browse files
authored
Fix rate limiter not shutting down if there is an empty bucket at shutdown (discord-jda#2080)
1 parent 5ad660a commit 5d4eeb4

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/main/java/net/dv8tion/jda/internal/requests/ratelimit/BotRateLimiter.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,9 @@ private void cleanup()
150150
// If the requests of the bucket are drained and the reset is expired the bucket has no valuable information
151151
else if (bucket.requests.isEmpty() && bucket.reset <= getNow())
152152
entries.remove();
153+
// Remove empty buckets when the rate limiter is stopped
154+
else if (bucket.requests.isEmpty() && isStopped)
155+
entries.remove();
153156
}
154157
// Log how many buckets were removed
155158
size -= buckets.size();

0 commit comments

Comments
 (0)