8306959: (bf) CharBuffer.append(CharSequence,int,int) throws BufferOverflowException where IndexOutOfBoundsException expected

Reviewed-by: alanb
This commit is contained in:
Brian Burkhalter 2023-04-27 17:20:08 +00:00
parent eb358619df
commit 80fae514b1
11 changed files with 387 additions and 11 deletions

View file

@ -289,6 +289,8 @@ class Heap$Type$Buffer$RW$
private $Type$Buffer appendChars(CharSequence csq, int start, int end) {
checkSession();
Objects.checkFromToIndex(start, end, csq.length());
int length = end - start;
int pos = position();
int lim = limit();

View file

@ -2045,6 +2045,8 @@ public abstract sealed class $Type$Buffer
*/
public $Type$Buffer append(CharSequence csq, int start, int end) {
if (csq instanceof CharBuffer cb) {
Objects.checkFromToIndex(start, end, csq.length());
//
// the append method throws BufferOverflowException when
// there is insufficient space in the buffer