Updated Branches: refs/heads/master 39cc1509a -> 514df2fb4
CAMEL-6327: More work on new camel-netty-http component. Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/514df2fb Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/514df2fb Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/514df2fb Branch: refs/heads/master Commit: 514df2fb4fa05b6cec3f89b5805fcf3b8c0cd446 Parents: b67f5f9 Author: Claus Ibsen <[email protected]> Authored: Wed May 8 11:27:12 2013 +0200 Committer: Claus Ibsen <[email protected]> Committed: Wed May 8 11:31:50 2013 +0200 ---------------------------------------------------------------------- .../netty/http/NettyHttpReturnFaultTest.java | 2 - .../netty/handlers/ServerChannelHandler.java | 16 +++++--------- 2 files changed, 6 insertions(+), 12 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/514df2fb/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpReturnFaultTest.java ---------------------------------------------------------------------- diff --git a/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpReturnFaultTest.java b/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpReturnFaultTest.java index 3943297..36b6383 100644 --- a/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpReturnFaultTest.java +++ b/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpReturnFaultTest.java @@ -19,13 +19,11 @@ package org.apache.camel.component.netty.http; import org.apache.camel.Exchange; import org.apache.camel.Processor; import org.apache.camel.builder.RouteBuilder; -import org.junit.Ignore; import org.junit.Test; public class NettyHttpReturnFaultTest extends BaseNettyTest { @Test - @Ignore public void testHttpFault() throws Exception { Exchange exchange = template.request("netty-http:http://localhost:{{port}}/test", new Processor() { @Override http://git-wip-us.apache.org/repos/asf/camel/blob/514df2fb/components/camel-netty/src/main/java/org/apache/camel/component/netty/handlers/ServerChannelHandler.java ---------------------------------------------------------------------- diff --git a/components/camel-netty/src/main/java/org/apache/camel/component/netty/handlers/ServerChannelHandler.java b/components/camel-netty/src/main/java/org/apache/camel/component/netty/handlers/ServerChannelHandler.java index a054418..a509692 100644 --- a/components/camel-netty/src/main/java/org/apache/camel/component/netty/handlers/ServerChannelHandler.java +++ b/components/camel-netty/src/main/java/org/apache/camel/component/netty/handlers/ServerChannelHandler.java @@ -25,6 +25,7 @@ import org.apache.camel.component.netty.NettyConsumer; import org.apache.camel.component.netty.NettyHelper; import org.apache.camel.component.netty.NettyPayloadHelper; import org.apache.camel.util.CamelLogger; +import org.apache.camel.util.ExchangeHelper; import org.apache.camel.util.IOHelper; import org.jboss.netty.channel.ChannelFutureListener; import org.jboss.netty.channel.ChannelHandlerContext; @@ -133,16 +134,6 @@ public class ServerChannelHandler extends SimpleChannelUpstreamHandler { private void sendResponse(MessageEvent messageEvent, Exchange exchange) throws Exception { Object body = getResponseBody(exchange); - boolean failed = exchange.isFailed(); - if (failed && !consumer.getEndpoint().getConfiguration().isTransferExchange()) { - if (exchange.getException() != null) { - body = exchange.getException(); - } else { - // failed and no exception, must be a fault - body = exchange.getOut().getBody(); - } - } - if (body == null) { noReplyLogger.log("No payload to send as reply for exchange: " + exchange); if (consumer.getConfiguration().isDisconnectOnNoReply()) { @@ -177,6 +168,11 @@ public class ServerChannelHandler extends SimpleChannelUpstreamHandler { * @throws Exception is thrown if error getting the response body */ protected Object getResponseBody(Exchange exchange) throws Exception { + // if there was an exception then use that as response body + boolean exception = exchange.getException() != null && !consumer.getEndpoint().getConfiguration().isTransferExchange(); + if (exception) { + return exchange.getException(); + } if (exchange.hasOut()) { return NettyPayloadHelper.getOut(consumer.getEndpoint(), exchange); } else {
