class BufferedChecksumStreamInput extends FilterStreamInput {

    private static final int SKIP_BUFFER_SIZE = 1024;
    private static final ThreadLocal<byte[]> BUFFER = ThreadLocal.withInitial(() -> new byte[8]);

    private byte[] skipBuffer;
    private final Checksum digest;
    private final String source;

    public BufferedChecksumStreamInput(StreamInput in, String source, BufferedChecksumStreamInput reuse) {
        super(in);
        this.source = source;
        if (reuse == null) {
            this.digest = new BufferedChecksum(new CRC32());
        } else {
            this.digest = reuse.digest;
            digest.reset();
            this.skipBuffer = reuse.skipBuffer;
        }
    }

    public BufferedChecksumStreamInput(StreamInput in, String source) {
        this(in, source, null);
    }

    public long getChecksum() {
        return this.digest.getValue();
    }

    @Override
    public byte readByte() throws IOException {
        final byte b = delegate.readByte();
        digest.update(b);
        return b;
    }

    @Override
    public void readBytes(byte[] b, int offset, int len) throws IOException {
        delegate.readBytes(b, offset, len);
        digest.update(b, offset, len);
    }

    @Override
    public short readShort() throws IOException {<FILL_FUNCTION_BODY>}

    @Override
    public int readInt() throws IOException {
        final byte[] buf = BUFFER.get();
        readBytes(buf, 0, 4);
        return ((buf[0] & 0xFF) << 24) | ((buf[1] & 0xFF) << 16) | ((buf[2] & 0xFF) << 8) | (buf[3] & 0xFF);
    }

    @Override
    public long readLong() throws IOException {
        final byte[] buf = BUFFER.get();
        readBytes(buf, 0, 8);
        return (((long) (((buf[0] & 0xFF) << 24) | ((buf[1] & 0xFF) << 16) | ((buf[2] & 0xFF) << 8) | (buf[3] & 0xFF))) << 32)
            | ((((buf[4] & 0xFF) << 24) | ((buf[5] & 0xFF) << 16) | ((buf[6] & 0xFF) << 8) | (buf[7] & 0xFF)) & 0xFFFFFFFFL);
    }

    @Override
    @SuppressWarnings("sync-override")
    public void reset() throws IOException {
        delegate.reset();
        digest.reset();
    }

    @Override
    public int read() throws IOException {
        return readByte() & 0xFF;
    }

    @Override
    public boolean markSupported() {
        return delegate.markSupported();
    }

    @Override
    public long skip(long numBytes) throws IOException {
        if (numBytes < 0) {
            throw new IllegalArgumentException("numBytes must be >= 0, got " + numBytes);
        }
        if (skipBuffer == null) {
            skipBuffer = new byte[SKIP_BUFFER_SIZE];
        }
        assert skipBuffer.length == SKIP_BUFFER_SIZE;
        long skipped = 0;
        for (; skipped < numBytes; ) {
            final int step = (int) Math.min(SKIP_BUFFER_SIZE, numBytes - skipped);
            readBytes(skipBuffer, 0, step);
            skipped += step;
        }
        return skipped;
    }

    @Override
    public synchronized void mark(int readlimit) {
        delegate.mark(readlimit);
    }

    public void resetDigest() {
        digest.reset();
    }

    public String getSource() {
        return source;
    }
}

        final byte[] buf = BUFFER.get();
        readBytes(buf, 0, 2);
        return (short) (((buf[0] & 0xFF) << 8) | (buf[1] & 0xFF));
    
<methods>public int available() throws java.io.IOException,public void close() throws java.io.IOException,public org.elasticsearch.Version getVersion() ,public int read() throws java.io.IOException,public byte readByte() throws java.io.IOException,public void readBytes(byte[], int, int) throws java.io.IOException,public int readInt() throws java.io.IOException,public long readLong() throws java.io.IOException,public short readShort() throws java.io.IOException,public void reset() throws java.io.IOException,public void setVersion(org.elasticsearch.Version) <variables>protected final non-sealed org.elasticsearch.common.io.stream.StreamInput delegate