diff --git a/redisson/src/main/java/org/redisson/jcache/JCache.java b/redisson/src/main/java/org/redisson/jcache/JCache.java index 8e65e5728..60efec529 100644 --- a/redisson/src/main/java/org/redisson/jcache/JCache.java +++ b/redisson/src/main/java/org/redisson/jcache/JCache.java @@ -208,7 +208,7 @@ public class JCache extends RedissonObject implements Cache, CacheAs return f.handle((r, e) -> { if (e != null) { if (e instanceof CompletionException) { - throw (RuntimeException) e.getCause(); + e = e.getCause(); } throw new CompletionException(new CacheException(e)); } @@ -267,7 +267,7 @@ public class JCache extends RedissonObject implements Cache, CacheAs V val = loadValue(key); result.complete(val); } catch (Exception ex) { - result.completeExceptionally(ex); + result.completeExceptionally(new CacheException(ex)); } }); return; @@ -1046,7 +1046,7 @@ public class JCache extends RedissonObject implements Cache, CacheAs CompletableFuture> result = new CompletableFuture<>(); res.whenComplete((r, ex) -> { if (ex != null) { - result.completeExceptionally(ex); + result.completeExceptionally(new CacheException(ex)); return; } @@ -1095,7 +1095,7 @@ public class JCache extends RedissonObject implements Cache, CacheAs checkKey(key); String name = getRawName(key); - RFuture future = commandExecutor.evalReadAsync(name, codec, RedisCommands.EVAL_BOOLEAN, + CompletionStage future = commandExecutor.evalReadAsync(name, codec, RedisCommands.EVAL_BOOLEAN, "if redis.call('hexists', KEYS[1], ARGV[2]) == 0 then " + "return 0;" + "end;" @@ -1107,7 +1107,8 @@ public class JCache extends RedissonObject implements Cache, CacheAs + "return 1;", Arrays.asList(name, getTimeoutSetName(name)), System.currentTimeMillis(), encodeMapKey(key)); - return future; + future = handleException(future); + return new CompletableFutureWrapper<>(future); } @Override @@ -2942,11 +2943,11 @@ public class JCache extends RedissonObject implements Cache, CacheAs } RFuture future = removeValues(keys.toArray()); - CompletionStage f = future.thenApply(res -> { + CompletionStage f = future.thenAccept(res -> { cacheManager.getStatBean(this).addRemovals(res); cacheManager.getStatBean(this).addRemoveTime(currentNanoTime() - startTime); - return null; }); + f = handleException(f); return new CompletableFutureWrapper<>(f); }