An output stream 'es' can be obtained as encoder.wrap(os).
Normally, es.write(buf, off, len) throws IndexOutOfBoundException, if the referenced portion lies outside the buffer. In this case, nothing is written to the underlying output stream 'os'.
However, if (off + len) numerically overflows, then the call to write() will produce some output and only when reached the boundary of the buf will throw the exception.
This behavior looks inconsistent.