diff options
Diffstat (limited to 'sca-java-2.x/trunk')
-rw-r--r-- | sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/AbstractMessageProcessor.java | 35 |
1 files changed, 30 insertions, 5 deletions
diff --git a/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/AbstractMessageProcessor.java b/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/AbstractMessageProcessor.java index 35cc5769fb..6c6339c88e 100644 --- a/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/AbstractMessageProcessor.java +++ b/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/AbstractMessageProcessor.java @@ -18,6 +18,8 @@ */ package org.apache.tuscany.sca.binding.jms.provider; +import java.io.PrintWriter; +import java.io.StringWriter; import java.lang.reflect.InvocationTargetException; import java.util.logging.Logger; @@ -114,12 +116,35 @@ public abstract class AbstractMessageProcessor implements JMSMessageProcessor { try { ObjectMessage message = session.createObjectMessage(); - String causeMsg; - if (o instanceof RuntimeException) { - message.setObject(new ServiceRuntimeException(o.getMessage())); + if (o instanceof RuntimeException || o instanceof Error) { + int recursionKlugeDetector = 20; + Throwable rootCause = o; + Throwable deepRootCause = rootCause.getCause(); + do { + if (rootCause == deepRootCause) { + break; + } else if (deepRootCause != null) { + rootCause = deepRootCause; + } + + if (recursionKlugeDetector-- <= 0) { + break; + } + } while (deepRootCause != null); + + final StringWriter sw = new StringWriter(); + final PrintWriter pw = new PrintWriter(sw); + pw.print("Message = " + o.getMessage()); + StackTraceElement[] stackElements = o.getStackTrace(); + for (int i = 0; i < stackElements.length; i++) { + pw.print("\t>> \t at "); + pw.println(stackElements[i].toString()); + } + pw.flush(); + + message.setObject(new RuntimeException( sw.toString() )); } else { - // for a checked exception return the checked exception - message.setObject(o); + message.setObject(o); } message.setBooleanProperty(JMSBindingConstants.FAULT_PROPERTY, true); return message; |