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

Commit 0daff35

Browse filesBrowse files
dzubchiknicolas-grekas
authored andcommitted
[Lock] Prevent store exception break combined store
1 parent 8f6c52a commit 0daff35
Copy full SHA for 0daff35

File tree

Expand file treeCollapse file tree

2 files changed

+33
-3
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+33
-3
lines changed

‎src/Symfony/Component/Lock/Store/CombinedStore.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Lock/Store/CombinedStore.php
+8-3Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,14 @@ public function exists(Key $key)
171171
$storesCount = \count($this->stores);
172172

173173
foreach ($this->stores as $store) {
174-
if ($store->exists($key)) {
175-
++$successCount;
176-
} else {
174+
try {
175+
if ($store->exists($key)) {
176+
++$successCount;
177+
} else {
178+
++$failureCount;
179+
}
180+
} catch (\Exception $e) {
181+
$this->logger->debug('One store failed to check the "{resource}" lock.', ['resource' => $key, 'store' => $store, 'exception' => $e]);
177182
++$failureCount;
178183
}
179184

‎src/Symfony/Component/Lock/Tests/Store/CombinedStoreTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Lock/Tests/Store/CombinedStoreTest.php
+25Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,4 +351,29 @@ public function testDeleteDontStopOnFailure()
351351

352352
$this->store->delete($key);
353353
}
354+
355+
public function testExistsDontStopOnFailure()
356+
{
357+
$key = new Key(uniqid(__METHOD__, true));
358+
359+
$this->strategy
360+
->expects($this->any())
361+
->method('canBeMet')
362+
->willReturn(true);
363+
$this->strategy
364+
->expects($this->any())
365+
->method('isMet')
366+
->willReturn(false);
367+
$this->store1
368+
->expects($this->once())
369+
->method('exists')
370+
->willThrowException(new \Exception());
371+
$this->store2
372+
->expects($this->once())
373+
->method('exists')
374+
->with($key)
375+
->willReturn(false);
376+
377+
$this->assertFalse($this->store->exists($key));
378+
}
354379
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.