Fix RedisLettuceCache not catch decode exception during GET/GET_ALL.
@@ -162,11 +162,12 @@ public class RedisLettuceCache<K, V> extends AbstractExternalCache<K, V> {
try {
byte[] newKey = buildKey(key);
RedisFuture<byte[]> future = stringAsyncCommands.get(newKey);
- CacheGetResult result = new CacheGetResult(future.handle((valueBytes, ex) -> {
+ CacheGetResult<V> result = new CacheGetResult<>(future.handle((valueBytes, ex) -> {
if (ex != null) {
JetCacheExecutor.defaultExecutor().execute(() -> logError("GET", key, ex));
return new ResultData(ex);
} else {
+ try {
if (valueBytes != null) {
CacheValueHolder<V> holder = (CacheValueHolder<V>) valueDecoder.apply(valueBytes);
if (System.currentTimeMillis() >= holder.getExpireTime()) {
@@ -177,6 +178,10 @@ public class RedisLettuceCache<K, V> extends AbstractExternalCache<K, V> {
} else {
return new ResultData(CacheResultCode.NOT_EXISTS, null, null);
}
+ } catch (Exception exception) {
+ logError("GET", key, ex);
+ return new ResultData(ex);
+ }
}
}));
setTimeout(result);
@@ -198,11 +203,12 @@ public class RedisLettuceCache<K, V> extends AbstractExternalCache<K, V> {
return new MultiGetResult<K, V>(CacheResultCode.SUCCESS, null, resultMap);
}
RedisFuture<List<KeyValue<byte[],byte[]>>> mgetResults = stringAsyncCommands.mget(newKeys);
- MultiGetResult result = new MultiGetResult<K, V>(mgetResults.handle((list, ex) -> {
+ MultiGetResult<K, V> result = new MultiGetResult<>(mgetResults.handle((list, ex) -> {
if (ex != null) {
JetCacheExecutor.defaultExecutor().execute(() -> logError("GET_ALL", "keys(" + keys.size() + ")", ex));
return new ResultData(ex);
} else {
+ try {
for (int i = 0; i < list.size(); i++) {
KeyValue kv = list.get(i);
K key = keyList.get(i);
@@ -219,6 +225,10 @@ public class RedisLettuceCache<K, V> extends AbstractExternalCache<K, V> {
}
}
return new ResultData(CacheResultCode.SUCCESS, null, resultMap);
+ } catch (Exception exception) {
+ logError("GET_ALL", "keys(" + keys.size() + ")", ex);
+ return new ResultData(ex);
+ }
}
}));
setTimeout(result);
