Skip to content

Commit

Permalink
Consistently handle invocation exceptions in TypeProxyInvocationHandler
Browse files Browse the repository at this point in the history
Closes gh-30764
  • Loading branch information
jhoeller committed Jun 28, 2023
1 parent 6526e79 commit 3cb746c
Showing 1 changed file with 6 additions and 8 deletions.
Expand Up @@ -22,7 +22,6 @@
import java.lang.reflect.Field;
import java.lang.reflect.GenericArrayType;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Proxy;
Expand Down Expand Up @@ -204,19 +203,18 @@ public Object invoke(Object proxy, Method method, Object[] args) throws Throwabl
return forTypeProvider(new MethodInvokeTypeProvider(this.provider, method, -1));
}
else if (Type[].class == method.getReturnType() && ObjectUtils.isEmpty(args)) {
Type[] result = new Type[((Type[]) method.invoke(this.provider.getType())).length];
Object returnValue = ReflectionUtils.invokeMethod(method, this.provider.getType());
if (returnValue == null) {
return null;
}
Type[] result = new Type[((Type[]) returnValue).length];
for (int i = 0; i < result.length; i++) {
result[i] = forTypeProvider(new MethodInvokeTypeProvider(this.provider, method, i));
}
return result;
}

try {
return method.invoke(this.provider.getType(), args);
}
catch (InvocationTargetException ex) {
throw ex.getTargetException();
}
return ReflectionUtils.invokeMethod(method, this.provider.getType(), args);
}
}

Expand Down

0 comments on commit 3cb746c

Please sign in to comment.