Revert "Fix NoSuchElementException raised by ChannelInitializer"

This reverts commit 3c453f5dba.
This commit is contained in:
Trustin Lee 2013-12-07 10:57:13 +09:00
parent 643ce2f8c0
commit 3d54a323ca

View File

@ -60,19 +60,22 @@ public abstract class ChannelInitializer<C extends Channel> extends ChannelHandl
*/ */
protected abstract void initChannel(C ch) throws Exception; protected abstract void initChannel(C ch) throws Exception;
@Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public final void channelRegistered(ChannelHandlerContext ctx) throws Exception { @Override
public final void channelRegistered(ChannelHandlerContext ctx)
throws Exception {
boolean removed = false;
boolean success = false; boolean success = false;
try { try {
initChannel((C) ctx.channel()); initChannel((C) ctx.channel());
ctx.pipeline().remove(this); ctx.pipeline().remove(this);
removed = true;
ctx.fireChannelRegistered(); ctx.fireChannelRegistered();
success = true; success = true;
} catch (Throwable t) { } catch (Throwable t) {
logger.warn("Failed to initialize a channel. Closing: " + ctx.channel(), t); logger.warn("Failed to initialize a channel. Closing: " + ctx.channel(), t);
} finally { } finally {
if (!ctx.isRemoved()) { if (!removed) {
ctx.pipeline().remove(this); ctx.pipeline().remove(this);
} }
if (!success) { if (!success) {