diff options
Diffstat (limited to 'sca-java-1.x/branches/sca-java-1.6.1/modules/binding-jms-runtime/src/main/java')
-rw-r--r-- | sca-java-1.x/branches/sca-java-1.6.1/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/AbstractMessageProcessor.java | 38 |
1 files changed, 32 insertions, 6 deletions
diff --git a/sca-java-1.x/branches/sca-java-1.6.1/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/AbstractMessageProcessor.java b/sca-java-1.x/branches/sca-java-1.6.1/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/AbstractMessageProcessor.java index e2fc49834e..7f4a865604 100644 --- a/sca-java-1.x/branches/sca-java-1.6.1/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/AbstractMessageProcessor.java +++ b/sca-java-1.x/branches/sca-java-1.6.1/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/AbstractMessageProcessor.java @@ -19,6 +19,8 @@ package org.apache.tuscany.sca.binding.jms.provider; import java.lang.reflect.InvocationTargetException; +import java.io.PrintWriter; +import java.io.StringWriter; import java.util.logging.Logger; import javax.jms.JMSException; @@ -112,15 +114,39 @@ public abstract class AbstractMessageProcessor implements JMSMessageProcessor { return null; } try { - ObjectMessage message = session.createObjectMessage(); - String causeMsg; - if (o instanceof RuntimeException) { - message.setObject(new RuntimeException(o.getMessage())); - } else { - // for a checked exception return the checked exception + + 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{ message.setObject(o); } + message.setBooleanProperty(JMSBindingConstants.FAULT_PROPERTY, true); return message; |