code: private long skipInternal(long n) throws IOException {
      assert (stateChangeLock.isLocked());
      waitForAsyncReadComplete();
      if (isEndOfStream()) {
        return 0;
      }
      if (available() >= n) {
        // we can skip from the internal buffers
        int toSkip = (int) n;
        // We need to skip from both active buffer and read ahead buffer
        toSkip -= activeBuffer.remaining();
        assert(toSkip > 0); // skipping from activeBuffer already handled.
        activeBuffer.position(0);
        activeBuffer.flip();
        readAheadBuffer.position(toSkip + readAheadBuffer.position());
        swapBuffers();
        // Trigger async read to emptied read ahead buffer.
        readAsync();
        return n;
      } else {
        int skippedBytes = available();
        long toSkip = n - skippedBytes;
        activeBuffer.position(0);
        activeBuffer.flip();
        readAheadBuffer.position(0);
        readAheadBuffer.flip();
        long skippedFromInputStream = underlyingInputStream.skip(toSkip);
        readAsync();
        return skippedBytes + skippedFromInputStream;
      }
    }
docs: Internal skip function which should be called only from skip() api. The assumption is that
  the stateChangeLock is already acquired in the caller before calling this function.