We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents cfbc47e + 37b27d1 commit 8b8acedCopy full SHA for 8b8aced
src/Backoff.php
@@ -329,6 +329,7 @@ public function getWaitTime($attempt)
329
*/
330
protected function cap($waitTime)
331
{
332
+ $waitTime = $waitTime < 0 ? PHP_INT_MAX : $waitTime;
333
return is_int($this->getWaitCap())
334
? min($this->getWaitCap(), $waitTime)
335
: $waitTime;
tests/BackoffTest.php
@@ -151,6 +151,13 @@ public function testWaitCap()
151
$this->assertEquals(5000, $b->getWaitTime(2));
152
}
153
154
+ public function testWaitCapOverflow()
155
+ {
156
+ $b = new Backoff(1, new LinearStrategy(-1), 1000);
157
+
158
+ $this->assertEquals(1000, $b->getWaitTime(1));
159
+ }
160
161
public function testWait()
162
163
$b = new Backoff(1, new LinearStrategy(50));
0 commit comments