mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-26 22:34:27 +02:00
8306623: (bf) CharBuffer::allocate throws unexpected exception type with some CharSequences
Reviewed-by: alanb, lancea
This commit is contained in:
parent
d819debaa5
commit
e3ccaa6541
4 changed files with 74 additions and 5 deletions
|
@ -2045,8 +2045,17 @@ public abstract sealed class $Type$Buffer
|
|||
*/
|
||||
public $Type$Buffer append(CharSequence csq, int start, int end) {
|
||||
if (csq instanceof CharBuffer cb) {
|
||||
int pos = position();
|
||||
//
|
||||
// the append method throws BufferOverflowException when
|
||||
// there is insufficient space in the buffer
|
||||
//
|
||||
int length = end - start;
|
||||
int pos = position();
|
||||
int lim = limit();
|
||||
int rem = (pos <= lim) ? lim - pos : 0;
|
||||
if (length > rem)
|
||||
throw new BufferOverflowException();
|
||||
|
||||
put(pos, cb, start, length);
|
||||
position(pos + length);
|
||||
return this;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue