Better handling of ClosedChannelException