code: private void updateCurrentChunk(boolean lastChunk) throws IOException {
      // Early return for the most common case.
      if (mCurrentChunk != null && mCurrentChunk.writableBytes() > 0 && !lastChunk) {
        return;
      }
  
      if (mCurrentChunk == null) {
        if (!lastChunk) {
          mCurrentChunk = allocateBuffer();
        }
        return;
      }
  
      if (mCurrentChunk.writableBytes() == 0 || lastChunk) {
        try {
          if (mCurrentChunk.readableBytes() > 0) {
            for (DataWriter dataWriter : mDataWriters) {
              mCurrentChunk.retain();
              dataWriter.writeChunk(mCurrentChunk.duplicate());
            }
          } else {
            Preconditions.checkState(lastChunk);
          }
        } finally {
          // If the packet has bytes to read, we increment its refcount explicitly for every packet
          // writer. So we need to release here. If the packet has no bytes to read, then it has
          // to be the last packet. It needs to be released as well.
          mCurrentChunk.release();
          mCurrentChunk = null;
        }
      }
      if (!lastChunk) {
        mCurrentChunk = allocateBuffer();
      }
    }
docs: Updates the current chunk.
  
  @param lastChunk if the current packet is the last packet