--- old/src/java.naming/share/classes/com/sun/jndi/ldap/Connection.java 2015-10-07 20:52:37.000000000 +0100 +++ new/src/java.naming/share/classes/com/sun/jndi/ldap/Connection.java 2015-10-07 20:52:35.000000000 +0100 @@ -45,7 +45,6 @@ import java.lang.reflect.Method; import java.lang.reflect.InvocationTargetException; import java.util.Arrays; -import sun.misc.IOUtils; import javax.net.SocketFactory; /** @@ -862,7 +861,7 @@ } // read in seqlen bytes - byte[] left = IOUtils.readFully(in, seqlen, false); + byte[] left = readFully(in, seqlen); inbuf = Arrays.copyOf(inbuf, offset + left.length); System.arraycopy(left, 0, inbuf, offset, left.length); offset += left.length; @@ -957,6 +956,31 @@ } } + private static byte[] readFully(InputStream is, int length) + throws IOException + { + byte[] buf = new byte[Math.min(length, 8192)]; + int nread = 0; + while (nread < length) { + int bytesToRead; + if (nread >= buf.length) { // need to allocate a larger buffer + bytesToRead = Math.min(length - nread, buf.length + 8192); + if (buf.length < nread + bytesToRead) { + buf = Arrays.copyOf(buf, nread + bytesToRead); + } + } else { + bytesToRead = buf.length - nread; + } + int count = is.read(buf, nread, bytesToRead); + if (count < 0) { + if (buf.length != nread) + buf = Arrays.copyOf(buf, nread); + break; + } + nread += count; + } + return buf; + } // This code must be uncommented to run the LdapAbandonTest. /*public void sendSearchReqs(String dn, int numReqs) {