From 1c5bdf290960450deffa113148fca3e7f5216ac9 Mon Sep 17 00:00:00 2001 From: Victor Verbitsky Date: Fri, 11 Jul 2014 11:24:34 +0400 Subject: [PATCH] In some exception classes initCause(cause) is inaccessible. For example, in java.lang.reflect.InvocationTargetException --- .../org/switchyard/serial/graph/node/ThrowableNode.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/serial/base/src/main/java/org/switchyard/serial/graph/node/ThrowableNode.java b/serial/base/src/main/java/org/switchyard/serial/graph/node/ThrowableNode.java index 910d76021..061cd3a6e 100644 --- a/serial/base/src/main/java/org/switchyard/serial/graph/node/ThrowableNode.java +++ b/serial/base/src/main/java/org/switchyard/serial/graph/node/ThrowableNode.java @@ -150,7 +150,11 @@ public Object decompose(Graph graph) { Throwable throwable = newThrowable(clazz, getMessage()); Throwable cause = (Throwable)graph.decomposeReference(getCause()); if (cause != null) { - throwable.initCause(cause); + try { + throwable.initCause(cause); + } catch (IllegalStateException e) { + throwable = new RuntimeException(clazz.getName() + ": " + getMessage(), cause); + } } Object[] array = (Object[])graph.decomposeReference(getStackTrace()); if (array != null) {