You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ja...@apache.org on 2015/07/10 15:54:55 UTC
camel git commit: CAMEL-8949 - netty 3 doesn't handle TCP RST
Repository: camel
Updated Branches:
refs/heads/master d772b4f59 -> 821bddf58
CAMEL-8949 - netty 3 doesn't handle TCP RST
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/821bddf5
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/821bddf5
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/821bddf5
Branch: refs/heads/master
Commit: 821bddf5813f41804310849e47e04f742a8aeea4
Parents: d772b4f
Author: Jonathan Anstey <ja...@gmail.com>
Authored: Fri Jul 10 11:21:57 2015 -0230
Committer: Jonathan Anstey <ja...@gmail.com>
Committed: Fri Jul 10 11:21:57 2015 -0230
----------------------------------------------------------------------
.../HttpServerMultiplexChannelHandler.java | 31 +++++++++++++-------
1 file changed, 20 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/821bddf5/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/handlers/HttpServerMultiplexChannelHandler.java
----------------------------------------------------------------------
diff --git a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/handlers/HttpServerMultiplexChannelHandler.java b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/handlers/HttpServerMultiplexChannelHandler.java
index 2c1a753..2bcac76 100644
--- a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/handlers/HttpServerMultiplexChannelHandler.java
+++ b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/handlers/HttpServerMultiplexChannelHandler.java
@@ -16,6 +16,7 @@
*/
package org.apache.camel.component.netty.http.handlers;
+import java.io.IOException;
import java.nio.channels.ClosedChannelException;
import java.util.ArrayList;
import java.util.Iterator;
@@ -132,17 +133,25 @@ public class HttpServerMultiplexChannelHandler extends SimpleChannelUpstreamHand
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.", e.getCause());
- // 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);
- // Here we don't want to expose the exception detail to the client
- response.setContent(ChannelBuffers.copiedBuffer(new byte[]{}));
- ctx.getChannel().write(response).syncUninterruptibly();
- // close the channel after send error message
- ctx.getChannel().close();
+ if ("Broken pipe".equals(e.getCause().getMessage())) {
+ // Can't recover channel at this point. Only valid thing to do is close. A TCP RST is a possible cause for this.
+ // Note that trying to write to channel in this state will cause infinite recursion in netty 3.x
+ LOG.debug("Channel pipe is broken. Closing channel now.", e);
+ ctx.getChannel().close();
+ } else {
+ // we cannot throw the exception here
+ LOG.warn("HttpServerChannelHandler is not found as attachment to handle exception, send 404 back to the client.", e.getCause());
+ // 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);
+ // Here we don't want to expose the exception detail to the client
+ response.setContent(ChannelBuffers.copiedBuffer(new byte[]{}));
+
+ ctx.getChannel().write(response).syncUninterruptibly();
+ // close the channel after send error message
+ ctx.getChannel().close();
+ }
}
}
}