tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From antel...@apache.org
Subject svn commit: r1004156 - /tuscany/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/AbstractMessageProcessor.java
Date Mon, 04 Oct 2010 09:14:57 GMT
Author: antelder
Date: Mon Oct  4 09:14:52 2010
New Revision: 1004156

URL: http://svn.apache.org/viewvc?rev=1004156&view=rev
Log:
TUSCANY-3698: Apply patch from Padraig Myers to have the JMS binding handle unchecked exceptions
by sending back the full exceptioninfo in a RuntimeException

Modified:
    tuscany/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/AbstractMessageProcessor.java

Modified: tuscany/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/AbstractMessageProcessor.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/AbstractMessageProcessor.java?rev=1004156&r1=1004155&r2=1004156&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/AbstractMessageProcessor.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/AbstractMessageProcessor.java
Mon Oct  4 09:14:52 2010
@@ -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 AbstractMessagePro
         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;



Mime
View raw message