Skip to content

Commit

Permalink
Fix bug with obtain expired saga
Browse files Browse the repository at this point in the history
  • Loading branch information
mmasiukevich committed Aug 19, 2020
1 parent dc488d6 commit e35019b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/SagaStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ final class SagaStatus
*/
public static function create(string $value): self
{
if (false === \in_array($value, self::LIST, true))
if (\in_array($value, self::LIST, true) === false)
{
throw InvalidSagaStatus::create($value);
}
Expand Down
27 changes: 11 additions & 16 deletions src/SagasProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,26 +131,19 @@ function () use ($id, $context): \Generator
throw $throwable;
}

try
if ($saga !== null)
{
if ($saga !== null)
/** Non-expired saga */
if ($saga->expireDate() > now())
{
/** Non-expired saga */
if ($saga->expireDate() > now())
{
return $saga;
}
return $saga;
}

yield from $this->doCloseExpired($saga, $context);
yield from $this->doCloseExpired($saga, $context);

throw new LoadedExpiredSaga(
\sprintf('Unable to load the saga (ID: "%s") whose lifetime has expired', $id->toString())
);
}
}
finally
{
yield from $this->releaseMutex($id);
throw new LoadedExpiredSaga(
\sprintf('Unable to load the saga (ID: "%s") whose lifetime has expired', $id->toString())
);
}
}
);
Expand Down Expand Up @@ -266,6 +259,8 @@ private function doCloseExpired(Saga $saga, ServiceBusContext $context): \Genera

yield $this->save($saga, $context);
}

yield from $this->releaseMutex($saga->id());
}

/**
Expand Down

0 comments on commit e35019b

Please sign in to comment.