diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/memcached/MemcachedHttpCacheStorage.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/memcached/MemcachedHttpCacheStorage.java index a8ff8ff5a..fe66d2cc0 100644 --- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/memcached/MemcachedHttpCacheStorage.java +++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/memcached/MemcachedHttpCacheStorage.java @@ -208,8 +208,12 @@ public class MemcachedHttpCacheStorage extends AbstractBinaryCacheStorage casValue, final byte[] storageObject) throws ResourceIOException { - final CASResponse casResult = client.cas(storageKey, casValue.getCas(), storageObject); - return casResult == CASResponse.OK; + try { + final CASResponse casResult = client.cas(storageKey, casValue.getCas(), storageObject); + return casResult == CASResponse.OK; + } catch (final OperationTimeoutException ex) { + throw new MemcachedOperationTimeoutException(ex); + } } @Override @@ -219,12 +223,16 @@ public class MemcachedHttpCacheStorage extends AbstractBinaryCacheStorage bulkRestore(final Collection storageKeys) throws ResourceIOException { - final Map storageObjectMap = client.getBulk(storageKeys); - final Map resultMap = new HashMap<>(storageObjectMap.size()); - for (final Map.Entry resultEntry: storageObjectMap.entrySet()) { - resultMap.put(resultEntry.getKey(), castAsByteArray(resultEntry.getValue())); + try { + final Map storageObjectMap = client.getBulk(storageKeys); + final Map resultMap = new HashMap<>(storageObjectMap.size()); + for (final Map.Entry resultEntry: storageObjectMap.entrySet()) { + resultMap.put(resultEntry.getKey(), castAsByteArray(resultEntry.getValue())); + } + return resultMap; + } catch (final OperationTimeoutException ex) { + throw new MemcachedOperationTimeoutException(ex); } - return resultMap; } }