fixed. Change flush() to flush(Channel channel), as the caller of flush() already checked the channel to make sure it is not null.