Skip to content

Commit

Permalink
Merge branch '6.2' into 6.3
Browse files Browse the repository at this point in the history
* 6.2:
  [Validator] Add missing validator translations in Polish language
  [HttpClient] Fix encoding some characters in query strings
  [SecurityBundle] Remove last usages of tag `security.remember_me_aware`
  [VarDumper] Dumping DateTime throws error if getTimezone is false
  Only update autoload_runtime.php when it changed
  [Intl] Update the ICU data to 73.2
  [HttpClient] Force int conversion for floated multiplier for GenericRetryStrategy
  [FrameworkBundle] Ignore missing directories in about command
  Revert "[Messenger] Respect `isRetryable` decision of the retry strategy when deciding if failed message should be re-delivered"
  [Validator][Translator] Fix xlf files for en & fr translations. Bug introduced by #50590
  Add missing EN and FR translations for newest constraints
  • Loading branch information
nicolas-grekas committed Jun 21, 2023
2 parents c8033c4 + 32cfe1e commit e92ae99
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 26 deletions.
7 changes: 3 additions & 4 deletions EventListener/SendFailedMessageForRetryListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,7 @@ public static function getSubscribedEvents(): array

private function shouldRetry(\Throwable $e, Envelope $envelope, RetryStrategyInterface $retryStrategy): bool
{
$isRetryable = $retryStrategy->isRetryable($envelope, $e);
if ($isRetryable && $e instanceof RecoverableExceptionInterface) {
if ($e instanceof RecoverableExceptionInterface) {
return true;
}

Expand All @@ -130,7 +129,7 @@ private function shouldRetry(\Throwable $e, Envelope $envelope, RetryStrategyInt
if ($e instanceof HandlerFailedException) {
$shouldNotRetry = true;
foreach ($e->getNestedExceptions() as $nestedException) {
if ($isRetryable && $nestedException instanceof RecoverableExceptionInterface) {
if ($nestedException instanceof RecoverableExceptionInterface) {
return true;
}

Expand All @@ -148,7 +147,7 @@ private function shouldRetry(\Throwable $e, Envelope $envelope, RetryStrategyInt
return false;
}

return $isRetryable;
return $retryStrategy->isRetryable($envelope, $e);
}

private function getRetryStrategyForTransport(string $alias): ?RetryStrategyInterface
Expand Down
23 changes: 1 addition & 22 deletions Tests/EventListener/SendFailedMessageForRetryListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function testRecoverableStrategyCausesRetry()
$senderLocator->expects($this->once())->method('has')->willReturn(true);
$senderLocator->expects($this->once())->method('get')->willReturn($sender);
$retryStategy = $this->createMock(RetryStrategyInterface::class);
$retryStategy->expects($this->once())->method('isRetryable')->willReturn(true);
$retryStategy->expects($this->never())->method('isRetryable');
$retryStategy->expects($this->once())->method('getWaitingTime')->willReturn(1000);
$retryStrategyLocator = $this->createMock(ContainerInterface::class);
$retryStrategyLocator->expects($this->once())->method('has')->willReturn(true);
Expand All @@ -78,27 +78,6 @@ public function testRecoverableStrategyCausesRetry()
$listener->onMessageFailed($event);
}

public function testRetryIsOnlyAllowedWhenPermittedByRetryStrategy()
{
$senderLocator = $this->createMock(ContainerInterface::class);
$senderLocator->expects($this->never())->method('has');
$senderLocator->expects($this->never())->method('get');
$retryStrategy = $this->createMock(RetryStrategyInterface::class);
$retryStrategy->expects($this->once())->method('isRetryable')->willReturn(false);
$retryStrategy->expects($this->never())->method('getWaitingTime');
$retryStrategyLocator = $this->createMock(ContainerInterface::class);
$retryStrategyLocator->expects($this->once())->method('has')->willReturn(true);
$retryStrategyLocator->expects($this->once())->method('get')->willReturn($retryStrategy);

$listener = new SendFailedMessageForRetryListener($senderLocator, $retryStrategyLocator);

$exception = new RecoverableMessageHandlingException('retry');
$envelope = new Envelope(new \stdClass());
$event = new WorkerMessageFailedEvent($envelope, 'my_receiver', $exception);

$listener->onMessageFailed($event);
}

public function testEnvelopeIsSentToTransportOnRetry()
{
$exception = new \Exception('no!');
Expand Down

0 comments on commit e92ae99

Please sign in to comment.