private void resolveAllRemainingChunks(Exception e) {
    lock.lock();
    try {
      ChunkData chunkData = chunksAwaitingResolution.poll();
      while (chunkData != null) {
        chunkData.resolveChunk(e);
        chunkData = chunksAwaitingResolution.poll();
      }
      chunkData = chunks.poll();
      while (chunkData != null) {
        chunkData.resolveChunk(e);
        chunkData = chunks.poll();
      }
      chunks.add(new ChunkData(null, null));
    } finally {
      lock.unlock();
    }
  }
Resolves all the remaining chunks with {@link ClosedChannelException}.
@param e the exception to use to resolve all the chunks.
ambry-commons/src/main/java/com/github/ambry/commons/ByteBufferAsyncWritableChannel.java