Skip to content

Commit

Permalink
More consistent handling of OperationTimeoutException in MemcachedHtt…
Browse files Browse the repository at this point in the history
…pCacheStorage
  • Loading branch information
ok2c committed Sep 29, 2023
1 parent 5f46cde commit 6105852
Showing 1 changed file with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,12 @@ protected byte[] getStorageObject(final CASValue<Object> casValue) throws Resour
@Override
protected boolean updateCAS(
final String storageKey, final CASValue<Object> 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
Expand All @@ -219,12 +223,16 @@ protected void delete(final String storageKey) throws ResourceIOException {

@Override
protected Map<String, byte[]> bulkRestore(final Collection<String> storageKeys) throws ResourceIOException {
final Map<String, ?> storageObjectMap = client.getBulk(storageKeys);
final Map<String, byte[]> resultMap = new HashMap<>(storageObjectMap.size());
for (final Map.Entry<String, ?> resultEntry: storageObjectMap.entrySet()) {
resultMap.put(resultEntry.getKey(), castAsByteArray(resultEntry.getValue()));
try {
final Map<String, ?> storageObjectMap = client.getBulk(storageKeys);
final Map<String, byte[]> resultMap = new HashMap<>(storageObjectMap.size());
for (final Map.Entry<String, ?> resultEntry: storageObjectMap.entrySet()) {
resultMap.put(resultEntry.getKey(), castAsByteArray(resultEntry.getValue()));
}
return resultMap;
} catch (final OperationTimeoutException ex) {
throw new MemcachedOperationTimeoutException(ex);
}
return resultMap;
}

}

0 comments on commit 6105852

Please sign in to comment.