jdk/src/java.base/share/classes/java/net/SocketOutputStream.java
changeset 43202 29180c8db039
parent 32649 2ee9017c7597
child 44534 a076dffbc2c1
equal deleted inserted replaced
43201:b4c682966e2a 43202:29180c8db039
     1 /*
     1 /*
     2  * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 1995, 2016, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
    95      * @param len the number of bytes that are written
    95      * @param len the number of bytes that are written
    96      * @exception IOException If an I/O error has occurred.
    96      * @exception IOException If an I/O error has occurred.
    97      */
    97      */
    98     private void socketWrite(byte b[], int off, int len) throws IOException {
    98     private void socketWrite(byte b[], int off, int len) throws IOException {
    99 
    99 
   100         if (len <= 0 || off < 0 || off + len > b.length) {
   100 
       
   101         if (len <= 0 || off < 0 || len > b.length - off) {
   101             if (len == 0) {
   102             if (len == 0) {
   102                 return;
   103                 return;
   103             }
   104             }
   104             throw new ArrayIndexOutOfBoundsException();
   105             throw new ArrayIndexOutOfBoundsException("len == " + len
       
   106                     + " off == " + off + " buffer length == " + b.length);
   105         }
   107         }
   106 
   108 
   107         FileDescriptor fd = impl.acquireFD();
   109         FileDescriptor fd = impl.acquireFD();
   108         try {
   110         try {
   109             socketWrite0(fd, b, off, len);
   111             socketWrite0(fd, b, off, len);