10000 bug #46797 [Messenger] Ceil waiting time when multiplier is a float o… · symfony/symfony@99fa193 · GitHub
[go: up one dir, main page]

Skip to content

Commit 99fa193

Browse files
bug #46797 [Messenger] Ceil waiting time when multiplier is a float on retry (WissameMekhilef)
This PR was submitted for the 6.1 branch but it was squashed and merged into the 4.4 branch instead. Discussion ---------- [Messenger] Ceil waiting time when multiplier is a float on retry | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | #46795 | License | MIT | Doc PR | Not required In the Messenger - MultiplierRetryStrategy the return type for the function `getWaitingTime` is int, however with the computation of that function we were returning a float, this is because float * int returns a float and the attribute $multiplier is a float. With this fix, we are rounding up the delay and casting into an int. Commits ------- 3b62a06 [Messenger] Ceil waiting time when multiplier is a float on retry
2 parents 0c38f36 + 3b62a06 commit 99fa193

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/Symfony/Component/Messenger/Retry/MultiplierRetryStrategy.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,6 @@ public function getWaitingTime(Envelope $message): int
8080
return $this->maxDelayMilliseconds;
8181
}
8282

83-
return $delay;
83+
return (int) ceil($delay);
8484
}
8585
}

src/Symfony/Component/Messenger/Tests/Retry/MultiplierRetryStrategyTest.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function testIsRetryableWithNoStamp()
5252
/**
5353
* @dataProvider getWaitTimeTests
5454
*/
55-
public function testGetWaitTime(int $delay, int $multiplier, int $maxDelay, int $previousRetries, int $expectedDelay)
55+
public function testGetWaitTime(int $delay, float $multiplier, int $maxDelay, int $previousRetries, int $expectedDelay)
5656
{
5757
$strategy = new MultiplierRetryStrategy(10, $delay, $multiplier, $maxDelay);
5858
$envelope = new Envelope(new \stdClass(), [new RedeliveryStamp($previousRetries)]);
@@ -83,5 +83,10 @@ public function getWaitTimeTests(): iterable
8383
// never a delay
8484
yield [0, 2, 10000, 0, 0];
8585
yield [0, 2, 10000, 1, 0];
86+
87+
// Float delay
88+
yield [1000, 1.5555, 5000, 0, 1000];
89+
yield [1000, 1.5555, 5000, 1, 1555];
90+
yield [1000, 1.5555, 5000, 2, 2419];
8691
}
8792
}

0 commit comments

Comments
 (0)
0