google / guava

Google core libraries for Java
Apache License 2.0
50.2k stars 10.91k forks source link

SmoothRateLimiter.SmoothBursty obtaining too many permits without failure #7130

Closed chenzhiguo closed 7 months ago

chenzhiguo commented 7 months ago

Description

I wrote a test case, but the test result did not meet expectations.

Example

@Test
    public void testTryAcquire_negative() {
        RateLimiter limiter = RateLimiter.create(5.0);
        Assertions.assertFalse(limiter.tryAcquire(5000, 0, SECONDS));
    }

Expected Behavior

Test success!

Actual Behavior

Test fail!

Packages

com.google.common.util.concurrent

Platforms

Java 8

Checklist

chenzhiguo commented 7 months ago

Okay, prefetching mode, first success, second failure