RFR: 8306623: (bf) CharBuffer::allocate throws unexpected exception type with some CharSequences

Alan Bateman alanb at openjdk.org
Tue Apr 25 06:30:10 UTC 2023


On Tue, 25 Apr 2023 01:44:14 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:

> When appending a `CharBuffer`, perform a specific check for buffer overflow before invoking `put()`.

Can you add a test to test/jdk/java/nio/Buffer/Basic-X.java.template, I think this regression was missed because this tests didn't check this case.

src/java.base/share/classes/java/nio/X-Buffer.java.template line 2050:

> 2048:             //
> 2049:             // pre-emptively check for overflow as put(int,CharBuffer,int,int)
> 2050:             // would throw IndexOutOfBoundsException instead

The comment is confusing, I think you just want to say that the append method throws BufferOverflowException when there is insufficient space in the buffer.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/13632#issuecomment-1521217228
PR Review Comment: https://git.openjdk.org/jdk/pull/13632#discussion_r1176057894


More information about the nio-dev mailing list