Merge branch 'stable-2.14' into stable-2.15

* stable-2.14:
  Fix for replenishing schedule

Change-Id: I150874f8f16c55483ad343c856c7bb99dae40b78
diff --git a/src/main/java/com/googlesource/gerrit/plugins/ratelimiter/PeriodicRateLimiter.java b/src/main/java/com/googlesource/gerrit/plugins/ratelimiter/PeriodicRateLimiter.java
index 203645d..cb86336 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/ratelimiter/PeriodicRateLimiter.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/ratelimiter/PeriodicRateLimiter.java
@@ -43,7 +43,8 @@
     this.maxPermits = permits;
     this.usedPermits = new AtomicInteger();
     this.replenishTask =
-        executor.scheduleAtFixedRate(this::replenishPermits, 1, timeLapse, TimeUnit.MINUTES);
+        executor.scheduleAtFixedRate(
+            this::replenishPermits, timeLapse, timeLapse, TimeUnit.MINUTES);
   }
 
   @Override
diff --git a/src/test/java/com/googlesource/gerrit/plugins/ratelimiter/PeriodicRateLimiterTest.java b/src/test/java/com/googlesource/gerrit/plugins/ratelimiter/PeriodicRateLimiterTest.java
index 0343d6b..1cb3764 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/ratelimiter/PeriodicRateLimiterTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/ratelimiter/PeriodicRateLimiterTest.java
@@ -68,7 +68,10 @@
   public void testReplenishPermitsIsScheduled() {
     verify(scheduledExecutorMock)
         .scheduleAtFixedRate(
-            any(), eq(1L), eq(DEFAULT_TIME_LAPSE_IN_MINUTES), eq(TimeUnit.MINUTES));
+            any(),
+            eq(DEFAULT_TIME_LAPSE_IN_MINUTES),
+            eq(DEFAULT_TIME_LAPSE_IN_MINUTES),
+            eq(TimeUnit.MINUTES));
   }
 
   @Test
@@ -77,7 +80,7 @@
     verify(scheduledExecutorMock)
         .scheduleAtFixedRate(
             runnableCaptor.capture(),
-            eq(1L),
+            eq(DEFAULT_TIME_LAPSE_IN_MINUTES),
             eq(DEFAULT_TIME_LAPSE_IN_MINUTES),
             eq(TimeUnit.MINUTES));
 
diff --git a/src/test/java/com/googlesource/gerrit/plugins/ratelimiter/WarningRateLimiterTest.java b/src/test/java/com/googlesource/gerrit/plugins/ratelimiter/WarningRateLimiterTest.java
index 4a0162f..0353a92 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/ratelimiter/WarningRateLimiterTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/ratelimiter/WarningRateLimiterTest.java
@@ -99,7 +99,10 @@
   public void testReplenishPermitsIsScheduled() {
     verify(scheduledExecutorMock1)
         .scheduleAtFixedRate(
-            any(), eq(1L), eq(DEFAULT_TIME_LAPSE_IN_MINUTES), eq(TimeUnit.MINUTES));
+            any(),
+            eq(DEFAULT_TIME_LAPSE_IN_MINUTES),
+            eq(DEFAULT_TIME_LAPSE_IN_MINUTES),
+            eq(TimeUnit.MINUTES));
   }
 
   @Test
@@ -108,7 +111,7 @@
     verify(scheduledExecutorMock1)
         .scheduleAtFixedRate(
             runnableCaptor.capture(),
-            eq(1L),
+            eq(DEFAULT_TIME_LAPSE_IN_MINUTES),
             eq(DEFAULT_TIME_LAPSE_IN_MINUTES),
             eq(TimeUnit.MINUTES));
 
diff --git a/src/test/java/com/googlesource/gerrit/plugins/ratelimiter/WarningUnlimitedRateLimiterTest.java b/src/test/java/com/googlesource/gerrit/plugins/ratelimiter/WarningUnlimitedRateLimiterTest.java
index b402e77..facabbe 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/ratelimiter/WarningUnlimitedRateLimiterTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/ratelimiter/WarningUnlimitedRateLimiterTest.java
@@ -73,7 +73,10 @@
   public void testReplenishPermitsIsScheduled() {
     verify(scheduledExecutorMock)
         .scheduleAtFixedRate(
-            any(), eq(1L), eq(DEFAULT_TIME_LAPSE_IN_MINUTES), eq(TimeUnit.MINUTES));
+            any(),
+            eq(DEFAULT_TIME_LAPSE_IN_MINUTES),
+            eq(DEFAULT_TIME_LAPSE_IN_MINUTES),
+            eq(TimeUnit.MINUTES));
   }
 
   @Test
@@ -82,7 +85,7 @@
     verify(scheduledExecutorMock)
         .scheduleAtFixedRate(
             runnableCaptor.capture(),
-            eq(1L),
+            eq(DEFAULT_TIME_LAPSE_IN_MINUTES),
             eq(DEFAULT_TIME_LAPSE_IN_MINUTES),
             eq(TimeUnit.MINUTES));