summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java
diff options
context:
space:
mode:
authorantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2010-10-04 09:14:52 +0000
committerantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2010-10-04 09:14:52 +0000
commit41ad12766287c7a9c798b1bd3da4b705d25fedc6 (patch)
tree2ebbf1037cc72e36022de48cd4e5a1e5c947aa2a /sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java
parentb0f380a49200cb65672139833a411d9e4a24b0fa (diff)
TUSCANY-3698: Apply patch from Padraig Myers to have the JMS binding handle unchecked exceptions by sending back the full exceptioninfo in a RuntimeException
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1004156 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java')
-rw-r--r--sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/AbstractMessageProcessor.java35
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;