camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [1/5] git commit: CAMEL-6327: More work on new camel-netty-http component.
Date Wed, 08 May 2013 09:32:06 GMT
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 <davsclaus@apache.org>
Authored: Wed May 8 11:27:12 2013 +0200
Committer: Claus Ibsen <davsclaus@apache.org>
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 {


Mime
View raw message