mirror of https://github.com/apache/nifi.git
NIFI-43: Do not throw InvocationTargetException if it is wrapping a RuntimeException; instead just throw the RuntimeException
This commit is contained in:
parent
73cc6cbe28
commit
e04a55d3a5
|
@ -42,6 +42,7 @@ public class ReflectionUtils {
|
||||||
* @throws IllegalAccessException
|
* @throws IllegalAccessException
|
||||||
*/
|
*/
|
||||||
public static void invokeMethodsWithAnnotation(final Class<? extends Annotation> annotation, final Object instance, final Object... args) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
public static void invokeMethodsWithAnnotation(final Class<? extends Annotation> annotation, final Object instance, final Object... args) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
|
try {
|
||||||
for (final Method method : instance.getClass().getMethods()) {
|
for (final Method method : instance.getClass().getMethods()) {
|
||||||
if (method.isAnnotationPresent(annotation)) {
|
if (method.isAnnotationPresent(annotation)) {
|
||||||
final boolean isAccessible = method.isAccessible();
|
final boolean isAccessible = method.isAccessible();
|
||||||
|
@ -80,6 +81,13 @@ public class ReflectionUtils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (final InvocationTargetException ite) {
|
||||||
|
if ( ite.getCause() instanceof RuntimeException ) {
|
||||||
|
throw (RuntimeException) ite.getCause();
|
||||||
|
} else {
|
||||||
|
throw ite;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue