jihoonson commented on a change in pull request #6090: Fix missing exception
handling as part of
`io.druid.java.util.http.client.netty.HttpClientPipelineFactory`
URL: https://github.com/apache/incubator-druid/pull/6090#discussion_r208732093
##########
File path:
java-util/src/main/java/io/druid/java/util/http/client/pool/ChannelResourceFactory.java
##########
@@ -109,6 +112,28 @@ public ChannelFuture generate(final String hostname)
final ChannelPipeline pipeline =
connectFuture.getChannel().getPipeline();
pipeline.addFirst("ssl", sslHandler);
+ pipeline.addLast("connectionErrorHandler", new
SimpleChannelUpstreamHandler()
+ {
+ private final Logger LOGGER = new
Logger(SimpleChannelUpstreamHandler.class);
Review comment:
I'm seeing this code.
```java
pipeline.addLast("connectionErrorHandler", new
SimpleChannelUpstreamHandler()
{
@Override
public void exceptionCaught(ChannelHandlerContext ctx,
ExceptionEvent e)
{
final Channel channel = ctx.getChannel();
if (channel == null) {
// For the case where this pipeline is not attached yet.
return;
}
if (channel.isOpen()) {
channel.close();
}
}
});
```
Looks like the exception is not properly set for `handshakeFuture`. What I
meant is like below:
```java
final ChannelFuture handshakeFuture =
Channels.future(connectFuture.getChannel());
pipeline.addLast("connectionErrorHandler", new
SimpleChannelUpstreamHandler()
{
@Override
public void exceptionCaught(ChannelHandlerContext ctx,
ExceptionEvent e)
{
final Channel channel = ctx.getChannel();
if (channel == null) {
// For the case where this pipeline is not attached yet.
handshakeFuture. setFailure(new ChannelException("Channel is
null. The context name is ..."));
}
else {
handshakeFuture.setFailure(e.getCause());
if (channel.isOpen()) {
channel.close();
}
}
}
});
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]