Fix NoSuchElementException raised by ChannelInitializer
This commit is contained in:
parent
40001a7a5b
commit
51428004b3
@ -60,22 +60,19 @@ public abstract class ChannelInitializer<C extends Channel> extends ChannelInbou
|
||||
*/
|
||||
protected abstract void initChannel(C ch) throws Exception;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public final void channelRegistered(ChannelHandlerContext ctx)
|
||||
throws Exception {
|
||||
boolean removed = false;
|
||||
@SuppressWarnings("unchecked")
|
||||
public final void channelRegistered(ChannelHandlerContext ctx) throws Exception {
|
||||
boolean success = false;
|
||||
try {
|
||||
initChannel((C) ctx.channel());
|
||||
ctx.pipeline().remove(this);
|
||||
removed = true;
|
||||
ctx.fireChannelRegistered();
|
||||
success = true;
|
||||
} catch (Throwable t) {
|
||||
logger.warn("Failed to initialize a channel. Closing: " + ctx.channel(), t);
|
||||
} finally {
|
||||
if (!removed) {
|
||||
if (!ctx.isRemoved()) {
|
||||
ctx.pipeline().remove(this);
|
||||
}
|
||||
if (!success) {
|
||||
|
Loading…
Reference in New Issue
Block a user