summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2010-10-06 12:06:59 +0000
committerantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2010-10-06 12:06:59 +0000
commit683db461f2666c7cfe50e1347ba4d992fc9319b9 (patch)
tree45163d5a5238980014fe8a124c042e5fbe1b0b36
parentbe7cd357835ea29b1aa40795d8c73287f857cb27 (diff)
TUSCANY-3698: Apply patch from Padraig Myers to update jms binding exception handling to return more info with unchecked exceptions. And associated itest updates
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1005001 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--sca-java-1.x/trunk/itest/jms-format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldReferenceImpl.java2
-rw-r--r--sca-java-1.x/trunk/itest/jms-nonscaclient-exceptions/src/test/java/org/apache/tuscany/sca/binding/jms/ExceptionsTestCase.java4
-rw-r--r--sca-java-1.x/trunk/itest/jms/src/test/java/org/apache/tuscany/sca/binding/jms/ExceptionsTestCase.java4
-rw-r--r--sca-java-1.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/AbstractMessageProcessor.java38
4 files changed, 37 insertions, 11 deletions
diff --git a/sca-java-1.x/trunk/itest/jms-format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldReferenceImpl.java b/sca-java-1.x/trunk/itest/jms-format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldReferenceImpl.java
index bb853673e8..c1bb35636f 100644
--- a/sca-java-1.x/trunk/itest/jms-format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldReferenceImpl.java
+++ b/sca-java-1.x/trunk/itest/jms-format/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldReferenceImpl.java
@@ -103,7 +103,7 @@ public class HelloWorldReferenceImpl implements HelloWorldReference {
try {
helloWorldServiceDontWrapSingle.throwUnChecked(person);
} catch (Exception e) {
- returnString += " " + e.getCause().getMessage();
+ returnString += " " + (e.getCause().getMessage().startsWith("Message = java.lang.RuntimeException: bla") ? "java.lang.RuntimeException: bla" : e.getCause().getMessage());
}
return returnString;
diff --git a/sca-java-1.x/trunk/itest/jms-nonscaclient-exceptions/src/test/java/org/apache/tuscany/sca/binding/jms/ExceptionsTestCase.java b/sca-java-1.x/trunk/itest/jms-nonscaclient-exceptions/src/test/java/org/apache/tuscany/sca/binding/jms/ExceptionsTestCase.java
index 1dec4a6f92..ba84ac08f4 100644
--- a/sca-java-1.x/trunk/itest/jms-nonscaclient-exceptions/src/test/java/org/apache/tuscany/sca/binding/jms/ExceptionsTestCase.java
+++ b/sca-java-1.x/trunk/itest/jms-nonscaclient-exceptions/src/test/java/org/apache/tuscany/sca/binding/jms/ExceptionsTestCase.java
@@ -104,7 +104,7 @@ public class ExceptionsTestCase {
Object o = ((ObjectMessage)m).getObject();
assertTrue(o instanceof RuntimeException);
assertTrue("java.lang.RuntimeException".equals(o.getClass().getName()));
- assertEquals("java.lang.RuntimeException: bla", ((RuntimeException)o).getMessage());
+ assertTrue(((RuntimeException)o).getMessage().startsWith("Message = java.lang.RuntimeException: bla"));
}
@Test
@@ -150,7 +150,7 @@ public class ExceptionsTestCase {
Object o = ((ObjectMessage)m).getObject();
assertTrue(o instanceof RuntimeException);
assertTrue("java.lang.RuntimeException".equals(o.getClass().getName()));
- assertEquals("java.lang.RuntimeException: bla", ((RuntimeException)o).getMessage());
+ assertTrue(((RuntimeException)o).getMessage().startsWith("Message = java.lang.RuntimeException: bla"));
}
@After
diff --git a/sca-java-1.x/trunk/itest/jms/src/test/java/org/apache/tuscany/sca/binding/jms/ExceptionsTestCase.java b/sca-java-1.x/trunk/itest/jms/src/test/java/org/apache/tuscany/sca/binding/jms/ExceptionsTestCase.java
index bd326b36d2..05001d2ad2 100644
--- a/sca-java-1.x/trunk/itest/jms/src/test/java/org/apache/tuscany/sca/binding/jms/ExceptionsTestCase.java
+++ b/sca-java-1.x/trunk/itest/jms/src/test/java/org/apache/tuscany/sca/binding/jms/ExceptionsTestCase.java
@@ -19,7 +19,7 @@
package org.apache.tuscany.sca.binding.jms;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import org.apache.tuscany.sca.host.embedded.SCADomain;
@@ -96,7 +96,7 @@ public class ExceptionsTestCase {
service.throwUnChecked();
fail();
} catch (Exception e) {
- assertEquals("java.lang.RuntimeException: bla", e.getCause().getMessage());
+ assertTrue(e.getCause().getMessage().startsWith("Message = java.lang.RuntimeException: bla"));
}
}
diff --git a/sca-java-1.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/AbstractMessageProcessor.java b/sca-java-1.x/trunk/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/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/AbstractMessageProcessor.java
+++ b/sca-java-1.x/trunk/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;