private DefaultChannelHandlerContext getContextOrDie(
     Class<? extends ChannelHandler> handlerType) {
   DefaultChannelHandlerContext ctx = (DefaultChannelHandlerContext) context(handlerType);
   if (ctx == null) {
     throw new NoSuchElementException(handlerType.getName());
   } else {
     return ctx;
   }
 }
  @Override
  public ChannelHandlerContext context(Class<? extends ChannelHandler> handlerType) {
    if (handlerType == null) {
      throw new NullPointerException("handlerType");
    }

    DefaultChannelHandlerContext ctx = head.next;
    for (; ; ) {
      if (ctx == null) {
        return null;
      }
      if (handlerType.isAssignableFrom(ctx.handler().getClass())) {
        return ctx;
      }
      ctx = ctx.next;
    }
  }