code: private void startDraining(boolean overflow) {
      byteBuffer.flip();
      if (overflow && byteBuffer.remaining() == 0) {
        byteBuffer = ByteBuffer.allocate(byteBuffer.capacity() * 2);
      } else {
        draining = true;
      }
    }
docs: Flips the buffer output buffer so we can start reading bytes from it. If we are starting to
  drain because there was overflow, and there aren't actually any characters to drain, then the
  overflow must be due to a small output buffer.