Fixed - RedissonRateLimiter acquire() blocks forever #1524

pull/1547/head
Nikita 7 years ago
parent 1bdc88cb93
commit dce544c18a

@ -153,7 +153,7 @@ public class RedissonRateLimiter extends RedissonObject implements RRateLimiter
public void run() { public void run() {
tryAcquireAsync(permits, promise, timeoutInMillis); tryAcquireAsync(permits, promise, timeoutInMillis);
} }
}, delay, TimeUnit.SECONDS); }, delay, TimeUnit.MILLISECONDS);
return; return;
} }

@ -19,11 +19,11 @@ public class RedissonRateLimiterTest extends BaseTest {
@Test @Test
public void testAcquire() { public void testAcquire() {
RRateLimiter rr = redisson.getRateLimiter("test"); RRateLimiter rr = redisson.getRateLimiter("acquire");
assertThat(rr.trySetRate(RateType.OVERALL, 10, 1, RateIntervalUnit.SECONDS)).isTrue(); assertThat(rr.trySetRate(RateType.OVERALL, 1, 5, RateIntervalUnit.SECONDS)).isTrue();
rr.acquire(1); for (int i = 0; i < 10; i++) {
rr.acquire(5); rr.acquire(1);
rr.acquire(4); }
assertThat(rr.tryAcquire()).isFalse(); assertThat(rr.tryAcquire()).isFalse();
} }

Loading…
Cancel
Save