Skip to content

Commit e35019b

Browse files
committed
Fix bug with obtain expired saga
1 parent dc488d6 commit e35019b

File tree

2 files changed

+12
-17
lines changed

2 files changed

+12
-17
lines changed

src/SagaStatus.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ final class SagaStatus
4747
*/
4848
public static function create(string $value): self
4949
{
50-
if (false === \in_array($value, self::LIST, true))
50+
if (\in_array($value, self::LIST, true) === false)
5151
{
5252
throw InvalidSagaStatus::create($value);
5353
}

src/SagasProvider.php

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -131,26 +131,19 @@ function () use ($id, $context): \Generator
131131
throw $throwable;
132132
}
133133

134-
try
134+
if ($saga !== null)
135135
{
136-
if ($saga !== null)
136+
/** Non-expired saga */
137+
if ($saga->expireDate() > now())
137138
{
138-
/** Non-expired saga */
139-
if ($saga->expireDate() > now())
140-
{
141-
return $saga;
142-
}
139+
return $saga;
140+
}
143141

144-
yield from $this->doCloseExpired($saga, $context);
142+
yield from $this->doCloseExpired($saga, $context);
145143

146-
throw new LoadedExpiredSaga(
147-
\sprintf('Unable to load the saga (ID: "%s") whose lifetime has expired', $id->toString())
148-
);
149-
}
150-
}
151-
finally
152-
{
153-
yield from $this->releaseMutex($id);
144+
throw new LoadedExpiredSaga(
145+
\sprintf('Unable to load the saga (ID: "%s") whose lifetime has expired', $id->toString())
146+
);
154147
}
155148
}
156149
);
@@ -266,6 +259,8 @@ private function doCloseExpired(Saga $saga, ServiceBusContext $context): \Genera
266259

267260
yield $this->save($saga, $context);
268261
}
262+
263+
yield from $this->releaseMutex($saga->id());
269264
}
270265

271266
/**

0 commit comments

Comments
 (0)