Properly handle InvocationTargetException in reflective JtaPlatform implementation

master
Juergen Hoeller 11 years ago
parent 519f78c3f5
commit 70164cb145
  1. 12
      spring-orm-hibernate4/src/main/java/org/springframework/orm/hibernate4/ConfigurableJtaPlatform.java

@ -17,6 +17,7 @@
package org.springframework.orm.hibernate4;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import javax.transaction.Status;
@ -136,8 +137,15 @@ class ConfigurableJtaPlatform implements InvocationHandler {
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
Method targetMethod = getClass().getMethod(method.getName(), method.getParameterTypes());
return targetMethod.invoke(this, args);
try {
return getClass().getMethod(method.getName(), method.getParameterTypes()).invoke(this, args);
}
catch (InvocationTargetException ex) {
throw ex.getTargetException();
}
catch (Throwable ex) {
throw new IllegalStateException("Failed to delegate to corresponding implementation method", ex);
}
}
/**

Loading…
Cancel
Save