You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2008/09/01 13:55:33 UTC
svn commit: r690945 - in /activemq/camel/trunk/components/camel-mina/src:
main/java/org/apache/camel/component/mina/MinaConsumer.java
test/java/org/apache/camel/component/mina/MinaTcpWithIoOutProcessorExceptionTest.java
Author: ningjiang
Date: Mon Sep 1 04:55:32 2008
New Revision: 690945
URL: http://svn.apache.org/viewvc?rev=690945&view=rev
Log:
CAMEL-873 send the exception back to the client
Modified:
activemq/camel/trunk/components/camel-mina/src/main/java/org/apache/camel/component/mina/MinaConsumer.java
activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaTcpWithIoOutProcessorExceptionTest.java
Modified: activemq/camel/trunk/components/camel-mina/src/main/java/org/apache/camel/component/mina/MinaConsumer.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-mina/src/main/java/org/apache/camel/component/mina/MinaConsumer.java?rev=690945&r1=690944&r2=690945&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-mina/src/main/java/org/apache/camel/component/mina/MinaConsumer.java (original)
+++ activemq/camel/trunk/components/camel-mina/src/main/java/org/apache/camel/component/mina/MinaConsumer.java Mon Sep 1 04:55:32 2008
@@ -109,7 +109,14 @@
} else {
body = MinaPayloadHelper.getIn(endpoint, exchange);
}
- // send message back
+ boolean failed = exchange.isFailed();
+ if (!endpoint.isTransferExchange() && failed) {
+ if (exchange.getException() != null) {
+ body = exchange.getException();
+ } else {
+ body = exchange.getFault().getBody();
+ }
+ }
if (body == null) {
// must close session if no data to write otherwise client will never receive a response
// and wait forever (if not timing out)
Modified: activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaTcpWithIoOutProcessorExceptionTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaTcpWithIoOutProcessorExceptionTest.java?rev=690945&r1=690944&r2=690945&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaTcpWithIoOutProcessorExceptionTest.java (original)
+++ activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaTcpWithIoOutProcessorExceptionTest.java Mon Sep 1 04:55:32 2008
@@ -22,6 +22,7 @@
import org.apache.camel.Processor;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.impl.DefaultExchange;
/**
* To unit test CAMEL-364.
@@ -35,8 +36,11 @@
public void testExceptionThrownInProcessor() {
String body = "Hello World";
- String out = (String) template.requestBody(uri, body);
- assertNull("Should not have sent data back", out);
+ Object result = template.sendBody(uri, body);
+ // The exception should be passed to the client
+ assertNotNull("the result should not be null", result);
+ assertEquals("result is IllegalArgumentException", result, "java.lang.IllegalArgumentException: Forced exception");
+
}
protected RouteBuilder createRouteBuilder() {