diff --git a/java-util/src/main/java/io/druid/java/util/http/client/NettyHttpClient.java b/java-util/src/main/java/io/druid/java/util/http/client/NettyHttpClient.java index 7058f3f11c3..c436cb5fe4d 100644 --- a/java-util/src/main/java/io/druid/java/util/http/client/NettyHttpClient.java +++ b/java-util/src/main/java/io/druid/java/util/http/client/NettyHttpClient.java @@ -278,18 +278,17 @@ public class NettyHttpClient extends AbstractHttpClient if (response != null) { handler.exceptionCaught(response, event.getCause()); } - removeHandlers(); try { - channel.close(); + if (channel.isOpen()) { + channel.close(); + } } catch (Exception e) { - // ignore + log.warn(e, "Error while closing channel"); } finally { channelResourceContainer.returnResource(); } - - context.sendUpstream(event); } @Override @@ -308,7 +307,6 @@ public class NettyHttpClient extends AbstractHttpClient log.warn("[%s] Channel disconnected before response complete", requestDesc); retVal.setException(new ChannelException("Channel disconnected")); } - context.sendUpstream(event); } private void removeHandlers() diff --git a/java-util/src/main/java/io/druid/java/util/http/client/pool/ChannelResourceFactory.java b/java-util/src/main/java/io/druid/java/util/http/client/pool/ChannelResourceFactory.java index 0c8c39d931e..04124b2b914 100644 --- a/java-util/src/main/java/io/druid/java/util/http/client/pool/ChannelResourceFactory.java +++ b/java-util/src/main/java/io/druid/java/util/http/client/pool/ChannelResourceFactory.java @@ -27,8 +27,11 @@ import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelException; import org.jboss.netty.channel.ChannelFuture; import org.jboss.netty.channel.ChannelFutureListener; +import org.jboss.netty.channel.ChannelHandlerContext; import org.jboss.netty.channel.ChannelPipeline; import org.jboss.netty.channel.Channels; +import org.jboss.netty.channel.ExceptionEvent; +import org.jboss.netty.channel.SimpleChannelUpstreamHandler; import org.jboss.netty.handler.ssl.SslHandler; import org.jboss.netty.util.Timer; @@ -111,6 +114,25 @@ public class ChannelResourceFactory implements ResourceFactory