DefaultChannelPipeline implements ChannelPipeline { @Override public final ChannelHandler first() { ChannelHandlerContext first = firstContext(); if (first == null) { return null; } return first.handler(); } protected  DefaultChannelPipeline(Channel channel); @Override final Channel channel(); @Override final ChannelPipeline addFirst(String name, ChannelHandler handler); @Override final ChannelPipeline addFirst(EventExecutorGroup group, String name, ChannelHandler handler); @Override final ChannelPipeline addLast(String name, ChannelHandler handler); @Override final ChannelPipeline addLast(EventExecutorGroup group, String name, ChannelHandler handler); @Override final ChannelPipeline addBefore(String baseName, String name, ChannelHandler handler); @Override final ChannelPipeline addBefore(
            EventExecutorGroup group, String baseName, String name, ChannelHandler handler); @Override final ChannelPipeline addAfter(String baseName, String name, ChannelHandler handler); @Override final ChannelPipeline addAfter(
            EventExecutorGroup group, String baseName, String name, ChannelHandler handler); final ChannelPipeline addFirst(ChannelHandler handler); @Override final ChannelPipeline addFirst(ChannelHandler... handlers); @Override final ChannelPipeline addFirst(EventExecutorGroup executor, ChannelHandler... handlers); final ChannelPipeline addLast(ChannelHandler handler); @Override final ChannelPipeline addLast(ChannelHandler... handlers); @Override final ChannelPipeline addLast(EventExecutorGroup executor, ChannelHandler... handlers); @Override final ChannelPipeline remove(ChannelHandler handler); @Override final ChannelHandler remove(String name); @SuppressWarnings("unchecked") @Override final T remove(Class<T> handlerType); @Override final ChannelHandler removeFirst(); @Override final ChannelHandler removeLast(); @Override final ChannelPipeline replace(ChannelHandler oldHandler, String newName, ChannelHandler newHandler); @Override final ChannelHandler replace(String oldName, String newName, ChannelHandler newHandler); @Override @SuppressWarnings("unchecked") final T replace(
            Class<T> oldHandlerType, String newName, ChannelHandler newHandler); @Override final ChannelHandler first(); @Override final ChannelHandlerContext firstContext(); @Override final ChannelHandler last(); @Override final ChannelHandlerContext lastContext(); @Override final ChannelHandler get(String name); @SuppressWarnings("unchecked") @Override final T get(Class<T> handlerType); @Override final ChannelHandlerContext context(String name); @Override final ChannelHandlerContext context(ChannelHandler handler); @Override final ChannelHandlerContext context(Class<? extends ChannelHandler> handlerType); @Override final List<String> names(); @Override final Map<String, ChannelHandler> toMap(); @Override final Iterator<Map.Entry<String, ChannelHandler>> iterator(); @Override final String toString(); @Override final ChannelPipeline fireChannelRegistered(); @Override final ChannelPipeline fireChannelUnregistered(); @Override final ChannelPipeline fireChannelActive(); @Override final ChannelPipeline fireChannelInactive(); @Override final ChannelPipeline fireExceptionCaught(Throwable cause); @Override final ChannelPipeline fireUserEventTriggered(Object event); @Override final ChannelPipeline fireChannelRead(Object msg); @Override final ChannelPipeline fireChannelReadComplete(); @Override final ChannelPipeline fireChannelWritabilityChanged(); @Override final ChannelFuture bind(SocketAddress localAddress); @Override final ChannelFuture connect(SocketAddress remoteAddress); @Override final ChannelFuture connect(SocketAddress remoteAddress, SocketAddress localAddress); @Override final ChannelFuture disconnect(); @Override final ChannelFuture close(); @Override final ChannelFuture deregister(); @Override final ChannelPipeline flush(); @Override final ChannelFuture bind(SocketAddress localAddress, ChannelPromise promise); @Override final ChannelFuture connect(SocketAddress remoteAddress, ChannelPromise promise); @Override final ChannelFuture connect(
            SocketAddress remoteAddress, SocketAddress localAddress, ChannelPromise promise); @Override final ChannelFuture disconnect(ChannelPromise promise); @Override final ChannelFuture close(ChannelPromise promise); @Override final ChannelFuture deregister(final ChannelPromise promise); @Override final ChannelPipeline read(); @Override final ChannelFuture write(Object msg); @Override final ChannelFuture write(Object msg, ChannelPromise promise); @Override final ChannelFuture writeAndFlush(Object msg, ChannelPromise promise); @Override final ChannelFuture writeAndFlush(Object msg); @Override final ChannelPromise newPromise(); @Override final ChannelProgressivePromise newProgressivePromise(); @Override final ChannelFuture newSucceededFuture(); @Override final ChannelFuture newFailedFuture(Throwable cause); @Override final ChannelPromise voidPromise();  }
@Test public void testFirstHandlerEmptyPipeline() throws Exception { ChannelPipeline pipeline = new LocalChannel().pipeline(); assertNull(pipeline.first()); }