File tree Expand file tree Collapse file tree 2 files changed +8
-0
lines changed Expand file tree Collapse file tree 2 files changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -329,6 +329,7 @@ public function getWaitTime($attempt)
329
329
*/
330
330
protected function cap ($ waitTime )
331
331
{
332
+ $ waitTime = $ waitTime < 0 ? PHP_INT_MAX : $ waitTime ;
332
333
return is_int ($ this ->getWaitCap ())
333
334
? min ($ this ->getWaitCap (), $ waitTime )
334
335
: $ waitTime ;
Original file line number Diff line number Diff line change @@ -151,6 +151,13 @@ public function testWaitCap()
151
151
$ this ->assertEquals (5000 , $ b ->getWaitTime (2 ));
152
152
}
153
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
+
154
161
public function testWait ()
155
162
{
156
163
$ b = new Backoff (1 , new LinearStrategy (50 ));
You can’t perform that action at this time.
0 commit comments