RFR: 8266320: (bf) ReadOnlyBufferException in heap buffer put(String, int, int) should not be conditional [v3]
Brian Burkhalter
bpb at openjdk.java.net
Mon May 3 17:31:51 UTC 2021
On Sat, 1 May 2021 16:36:48 GMT, Alan Bateman <alanb at openjdk.org> wrote:
>>> would expect this case to be covered by an existing test already.
>>
>> Upon closer inspection this line seems to cover it already. It also establishes the existing behavior to be throwing `ReadOnlyBufferException` and not `BufferOverflowException`. Should I undo the added test in `Basic-X.java.template` and not add the bug id to `Basic.java`?
>>
>> https://github.com/openjdk/jdk/blob/5c083e8560ce9cc78615e3149a558206724cff53/test/jdk/java/nio/Buffer/Basic-X.java.template#L1003
>
> Yes, I expected it was tested already so I think you can drop the change to Basic-X.java.template from the patch.
>
> That leaves the change to throw ReadOnlyBufferException unconditionally. As I said, if someone were to invoke this method on a read-only CharBuffer and with an out of range start or end index then ReadOnlyBufferException or IndexOutOfBoundsException are applicable. Existing behavior is to throw IOOBE. It's possible, but probably unlikely, that the behavior change will be observed by someone. A Release Note could be helpful.
Probably order of checks with respect to read-only, IOOBEs, and over/underflow has changed in various places and needs to be reviewed.
-------------
PR: https://git.openjdk.java.net/jdk/pull/3809
More information about the nio-dev
mailing list