Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotfix: Catch Throwable instead of Exception in LockingMiddleware #160

Open
wants to merge 1 commit into
base: 1.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Plugins/LockingMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class LockingMiddleware implements Middleware
* @param object $command
* @param callable $next
*
* @throws \Exception
* @throws \Throwable
*
* @return mixed|void
*/
Expand All @@ -43,7 +43,7 @@ public function execute($command, callable $next)

try {
$returnValue = $this->executeQueuedJobs();
} catch (\Exception $e) {
} catch (\Throwable $e) {
$this->isExecuting = false;
$this->queue = [];
throw $e;
Expand Down
20 changes: 20 additions & 0 deletions tests/Plugins/LockingMiddlewareTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,26 @@ public function testExceptionsDoNotLeaveTheCommandBusLocked()
);
}

public function testErrorDoNotLeaveTheCommandBusLocked()
{
$next = function () {
throw new \Error();
};

try {
$this->lockingMiddleware->execute(new AddTaskCommand(), $next);
} catch (\Error $e) {
}

$next2 = function () use (&$executed) {
return true;
};
$this->assertTrue(
$this->lockingMiddleware->execute(new AddTaskCommand(), $next2),
'Second command was not executed'
);
}

public function testExceptionsDoNotLeaveQueuedCommandsInTheBus()
{
$next = function () {
Expand Down