@Override
    public int read() throws IOException {
        final int c = super.read();
        if (c >= 0)
            dataLength++;
        checkLength(c == -1);
        return c;
    }
{@inheritDoc}

@throws SdkClientException
            if the data length read has exceeded the expected total, or
            if the total data length is not the same as the expected
            total.
aws-java-sdk-core/src/main/java/com/amazonaws/util/LengthCheckInputStream.java