Skip to content

Commit 02e7358

Browse files
author
Stephane Landelle
committed
minor clean up: finishChannel
1 parent d4170ac commit 02e7358

File tree

1 file changed

+11
-15
lines changed

1 file changed

+11
-15
lines changed

src/main/java/com/ning/http/client/providers/netty/NettyAsyncHttpProvider.java

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1024,23 +1024,19 @@ private void closeChannel(final ChannelHandlerContext ctx) {
10241024
private void finishChannel(final ChannelHandlerContext ctx) {
10251025
ctx.setAttachment(DiscardEvent.INSTANCE);
10261026

1027-
// The channel may have already been removed if a timeout occurred, and this method may be called just after.
1028-
if (ctx.getChannel() == null) {
1029-
return;
1030-
}
1031-
1032-
LOGGER.debug("Closing Channel {} ", ctx.getChannel());
1033-
1034-
try {
1035-
ctx.getChannel().close();
1036-
} catch (Throwable t) {
1037-
LOGGER.debug("Error closing a connection", t);
1038-
}
1027+
Channel channel = ctx.getChannel();
10391028

1040-
if (ctx.getChannel() != null) {
1041-
openChannels.remove(ctx.getChannel());
1029+
// The channel may have already been removed if a timeout occurred, and this method may be called just after.
1030+
if (channel != null) {
1031+
// FIXME can the context channel really be null?
1032+
LOGGER.debug("Closing Channel {} ", ctx.getChannel());
1033+
try {
1034+
channel.close();
1035+
} catch (Throwable t) {
1036+
LOGGER.debug("Error closing a connection", t);
1037+
}
1038+
openChannels.remove(channel);
10421039
}
1043-
10441040
}
10451041

10461042
@Override

0 commit comments

Comments
 (0)