A DESCRIPTION OF THE REQUEST :
OutputStream.write(byte b[], int off, int len) does some unnecessary checks in order to detect out of bounds condition. The code could be simplified. Here is proposed patch:
--- OutputStream.java.prev Wed Dec 05 17:52:44 2007
+++ OutputStream.java Wed Jan 02 14:28:21 2008
@@ -107,8 +107,7 @@
public void write(byte b[], int off, int len) throws IOException {
if (b == null) {
throw new NullPointerException();
- } else if ((off < 0) || (off > b.length) || (len < 0) ||
- ((off + len) > b.length) || ((off + len) < 0)) {
+ } else if (off < 0 || len < 0 || len > b.length - off) {
throw new IndexOutOfBoundsException();
} else if (len == 0) {
return;
JUSTIFICATION :
it makes code cleaner
OutputStream.write(byte b[], int off, int len) does some unnecessary checks in order to detect out of bounds condition. The code could be simplified. Here is proposed patch:
--- OutputStream.java.prev Wed Dec 05 17:52:44 2007
+++ OutputStream.java Wed Jan 02 14:28:21 2008
@@ -107,8 +107,7 @@
public void write(byte b[], int off, int len) throws IOException {
if (b == null) {
throw new NullPointerException();
- } else if ((off < 0) || (off > b.length) || (len < 0) ||
- ((off + len) > b.length) || ((off + len) < 0)) {
+ } else if (off < 0 || len < 0 || len > b.length - off) {
throw new IndexOutOfBoundsException();
} else if (len == 0) {
return;
JUSTIFICATION :
it makes code cleaner
- duplicates
-
JDK-8191516 OutputStream.write(byte[],int,int) could have fewer parameter bounds checks
- Closed