Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Lock] Prevent store exception break combined store #39476

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

Merged
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
[Lock] Prevent store exception break combined store
  • Loading branch information
dzubchik authored and nicolas-grekas committed Dec 14, 2020
commit 0daff35bae09f8feda23bcfed081c797fc1aa526
11 changes: 8 additions & 3 deletions 11 src/Symfony/Component/Lock/Store/CombinedStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,14 @@ public function exists(Key $key)
$storesCount = \count($this->stores);

foreach ($this->stores as $store) {
if ($store->exists($key)) {
++$successCount;
} else {
try {
if ($store->exists($key)) {
++$successCount;
} else {
++$failureCount;
}
} catch (\Exception $e) {
$this->logger->debug('One store failed to check the "{resource}" lock.', ['resource' => $key, 'store' => $store, 'exception' => $e]);
++$failureCount;
}

Expand Down
25 changes: 25 additions & 0 deletions 25 src/Symfony/Component/Lock/Tests/Store/CombinedStoreTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -351,4 +351,29 @@ public function testDeleteDontStopOnFailure()

$this->store->delete($key);
}

public function testExistsDontStopOnFailure()
{
$key = new Key(uniqid(__METHOD__, true));

$this->strategy
->expects($this->any())
->method('canBeMet')
->willReturn(true);
$this->strategy
->expects($this->any())
->method('isMet')
->willReturn(false);
$this->store1
->expects($this->once())
->method('exists')
->willThrowException(new \Exception());
$this->store2
->expects($this->once())
->method('exists')
->with($key)
->willReturn(false);

$this->assertFalse($this->store->exists($key));
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.