From 548b4e48988c2575ce44e7ff62fe274e56432549 Mon Sep 17 00:00:00 2001 From: Nikita Koksharov Date: Wed, 30 Jun 2021 11:51:58 +0300 Subject: [PATCH] Fixed - UndeclaredThrowableException is thrown when cache down while executing RLiveObjectService.get() method #3697 --- .../redisson/liveobject/core/LiveObjectInterceptor.java | 9 +++++++-- .../org/redisson/liveobject/core/RMapInterceptor.java | 9 +++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/redisson/src/main/java/org/redisson/liveobject/core/LiveObjectInterceptor.java b/redisson/src/main/java/org/redisson/liveobject/core/LiveObjectInterceptor.java index 605fde691..e85babc0e 100644 --- a/redisson/src/main/java/org/redisson/liveobject/core/LiveObjectInterceptor.java +++ b/redisson/src/main/java/org/redisson/liveobject/core/LiveObjectInterceptor.java @@ -28,6 +28,7 @@ import org.redisson.command.CommandBatchService; import org.redisson.liveobject.misc.ClassUtils; import org.redisson.liveobject.resolver.NamingScheme; +import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; /** @@ -80,7 +81,7 @@ public class LiveObjectInterceptor { @FieldValue("liveObjectLiveMap") RMap map, @FieldProxy("liveObjectLiveMap") Setter mapSetter, @FieldProxy("liveObjectLiveMap") Getter mapGetter - ) throws Exception { + ) throws Throwable { if ("setLiveObjectId".equals(method.getName())) { if (args[0].getClass().isArray()) { throw new UnsupportedOperationException("RId value cannot be an array."); @@ -130,7 +131,11 @@ public class LiveObjectInterceptor { return deleteFuture.getNow() > 0; } - return method.invoke(map, args); + try { + return method.invoke(map, args); + } catch (InvocationTargetException e) { + throw e.getCause(); + } } diff --git a/redisson/src/main/java/org/redisson/liveobject/core/RMapInterceptor.java b/redisson/src/main/java/org/redisson/liveobject/core/RMapInterceptor.java index 66c6f789b..45e852f74 100644 --- a/redisson/src/main/java/org/redisson/liveobject/core/RMapInterceptor.java +++ b/redisson/src/main/java/org/redisson/liveobject/core/RMapInterceptor.java @@ -15,6 +15,7 @@ */ package org.redisson.liveobject.core; +import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import org.redisson.api.RMap; @@ -35,7 +36,11 @@ public class RMapInterceptor { @Origin Method method, @AllArguments Object[] args, @FieldValue("liveObjectLiveMap") RMap map - ) throws Exception { - return method.invoke(map, args); + ) throws Throwable { + try { + return method.invoke(map, args); + } catch (InvocationTargetException e) { + throw e.getCause(); + } } }