8266078: Reader.read(CharBuffer) advances Reader position for read-only Charbuffers

Reviewed-by: rriggs, alanb, chegar
This commit is contained in:
Brian Burkhalter 2021-04-29 15:54:11 +00:00
parent 2a03739530
commit 5f15666092
2 changed files with 71 additions and 0 deletions

View file

@ -27,6 +27,7 @@ package java.io;
import java.nio.CharBuffer;
import java.nio.ReadOnlyBufferException;
import java.util.Objects;
/**
@ -184,6 +185,9 @@ public abstract class Reader implements Readable, Closeable {
* @since 1.5
*/
public int read(CharBuffer target) throws IOException {
if (target.isReadOnly())
throw new ReadOnlyBufferException();
int nread;
if (target.hasArray()) {
char[] cbuf = target.array();