private void testNegative(final int readLimit) throws IOException {
        byte[] bytes = new byte[100];
        for (int i=0; i < bytes.length; i++)
            bytes[i] = (byte)i;
        // buffer of 10 bytes
        BufferedInputStream bis =
            new BufferedInputStream(new ByteArrayInputStream(bytes), 10);
        // skip 10 bytes
        bis.skip(10);
        bis.mark(readLimit);   // 1 byte short in buffer size
        // read 30 bytes in total, with internal buffer incread to 20
        bis.read(new byte[20]);
        try {
            bis.reset();
            fail();
        } catch(IOException ex) {
            assertEquals("Resetting to invalid mark", ex.getMessage());
        }
    }
This test demonstrates why we should call mark(Integer.MAX_VALUE) instead of
mark(-1).
aws-java-sdk-core/src/test/java/com/amazonaws/internal/BufferedInputStreamResetTest.java