[jdk9] (XS) RFR: 8165243: Base64.Encoder.wrap(os).write(byte[], int, int) with incorrect arguments should not produce output

Ivan Gerasimov ivan.gerasimov at oracle.com
Thu Sep 1 16:40:12 UTC 2016


An encoding output stream 'es' can be obtained as encoder.wrap(os).
Normally, es.write(buf, off, len) throws IndexOutOfBoundException, if 
the referenced portion lies outside of the buffer.
In this case, nothing is written to the underlying output stream 'os'.

However, if (off + len) overflows, then the call to write() will produce 
some output, and only when it reaches the boundary of the buf will it 
throw the exception.

This behavior looks inconsistent.

Would you please help review the simple fix?

BUGURL: https://bugs.openjdk.java.net/browse/JDK-8165243
WEBREV: http://cr.openjdk.java.net/~igerasim/8165243/00/webrev/

With kind regards,

More information about the core-libs-dev mailing list