Skip to content

Commit 0f5e0f4

Browse files
Merge branch '4.4' into 5.1
* 4.4: Fix EncoderInterface::encode() return type [Lock] Prevent store exception break combined store
2 parents aed75dd + 8017f2e commit 0f5e0f4

File tree

2 files changed

+33
-3
lines changed

2 files changed

+33
-3
lines changed

Store/CombinedStore.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,14 @@ public function exists(Key $key)
158158
$storesCount = \count($this->stores);
159159

160160
foreach ($this->stores as $store) {
161-
if ($store->exists($key)) {
162-
++$successCount;
163-
} else {
161+
try {
162+
if ($store->exists($key)) {
163+
++$successCount;
164+
} else {
165+
++$failureCount;
166+
}
167+
} catch (\Exception $e) {
168+
$this->logger->debug('One store failed to check the "{resource}" lock.', ['resource' => $key, 'store' => $store, 'exception' => $e]);
164169
++$failureCount;
165170
}
166171

Tests/Store/CombinedStoreTest.php

Lines 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)