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