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 2015/01/28 10:56:20 UTC
[2/3] camel git commit: CAMEL-8289 Don't send out error message to
the client if the connection is closed.
CAMEL-8289 Don't send out error message to the client if the connection is closed.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/2bb61283
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/2bb61283
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/2bb61283
Branch: refs/heads/camel-2.14.x
Commit: 2bb61283748bbef1bbec8f60b3a98e34f3000235
Parents: 383b4c4
Author: Willem Jiang <wi...@gmail.com>
Authored: Wed Jan 28 16:58:13 2015 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Wed Jan 28 17:47:53 2015 +0800
----------------------------------------------------------------------
.../HttpServerMultiplexChannelHandler.java | 23 +++++++++++++-------
1 file changed, 15 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/2bb61283/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/handlers/HttpServerMultiplexChannelHandler.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/handlers/HttpServerMultiplexChannelHandler.java b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/handlers/HttpServerMultiplexChannelHandler.java
index 601d689..a6027e4 100644
--- a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/handlers/HttpServerMultiplexChannelHandler.java
+++ b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/handlers/HttpServerMultiplexChannelHandler.java
@@ -16,6 +16,7 @@
*/
package org.apache.camel.component.netty4.http.handlers;
+import java.nio.channels.ClosedChannelException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
@@ -133,14 +134,20 @@ public class HttpServerMultiplexChannelHandler extends SimpleChannelInboundHandl
if (handler != null) {
handler.exceptionCaught(ctx, cause);
} else {
- // we cannot throw the exception here
- LOG.warn("HttpServerChannelHandler is not found as attachment to handle exception, send 404 back to the client.", cause);
- // Now we just send 404 back to the client
- HttpResponse response = new DefaultHttpResponse(HTTP_1_1, NOT_FOUND);
- response.headers().set(Exchange.CONTENT_TYPE, "text/plain");
- response.headers().set(Exchange.CONTENT_LENGTH, 0);
- ctx.writeAndFlush(response);
- ctx.close();
+ if (cause instanceof ClosedChannelException) {
+ // The channel is closed so we do nothing here
+ LOG.debug("Channel already closed. Ignoring this exception.");
+ return;
+ } else {
+ // we cannot throw the exception here
+ LOG.warn("HttpServerChannelHandler is not found as attachment to handle exception, send 404 back to the client.", cause);
+ // Now we just send 404 back to the client
+ HttpResponse response = new DefaultHttpResponse(HTTP_1_1, NOT_FOUND);
+ response.headers().set(Exchange.CONTENT_TYPE, "text/plain");
+ response.headers().set(Exchange.CONTENT_LENGTH, 0);
+ ctx.writeAndFlush(response);
+ ctx.close();
+ }
}
}