8299600: Use Objects.check*() where appropriate in java.io

Reviewed-by: alanb, bpb
This commit is contained in:
Sergey Tsypanov 2023-01-06 21:01:21 +00:00 committed by Brian Burkhalter
parent 4a95c74b76
commit d086e82b3c
6 changed files with 28 additions and 27 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -26,6 +26,8 @@
package java.io;
import java.util.Objects;
/**
* Piped character-output streams.
*
@ -150,9 +152,8 @@ public class PipedWriter extends Writer {
public void write(char[] cbuf, int off, int len) throws IOException {
if (sink == null) {
throw new IOException("Pipe not connected");
} else if ((off | len | (off + len) | (cbuf.length - (off + len))) < 0) {
throw new IndexOutOfBoundsException();
}
Objects.checkFromIndexSize(off, len, cbuf.length);
sink.receive(cbuf, off, len);
}