Mercurial > hg > openjdk > jdk7 > jdk
changeset 3979:cd86fbf11e33
7034155: (ch) NullPointerException in sun.io.ch.IOUtil when OOM is thrown
Reviewed-by: forax
author | alanb |
---|---|
date | Wed, 06 Apr 2011 20:51:55 +0100 |
parents | 9f08a221e5f2 |
children | e279678f9f66 |
files | src/share/classes/sun/nio/ch/DatagramChannelImpl.java src/share/classes/sun/nio/ch/IOUtil.java |
diffstat | 2 files changed, 6 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/src/share/classes/sun/nio/ch/DatagramChannelImpl.java Mon Apr 04 11:55:05 2011 -0700 +++ b/src/share/classes/sun/nio/ch/DatagramChannelImpl.java Wed Apr 06 20:51:55 2011 +0100 @@ -388,9 +388,8 @@ // we must instead use a nonempty buffer, otherwise the call // will not block waiting for a datagram on some platforms. int newSize = Math.max(rem, 1); - ByteBuffer bb = null; + ByteBuffer bb = Util.getTemporaryDirectBuffer(newSize); try { - bb = Util.getTemporaryDirectBuffer(newSize); int n = receiveIntoNativeBuffer(fd, bb, newSize, 0); bb.flip(); if (n > 0 && rem > 0) @@ -482,9 +481,8 @@ assert (pos <= lim); int rem = (pos <= lim ? lim - pos : 0); - ByteBuffer bb = null; + ByteBuffer bb = Util.getTemporaryDirectBuffer(rem); try { - bb = Util.getTemporaryDirectBuffer(rem); bb.put(src); bb.flip(); // Do not update src until we see how many bytes were written @@ -766,10 +764,10 @@ // check multicast address is compatible with this socket if (group instanceof Inet4Address) { if (family == StandardProtocolFamily.INET6 && !Net.canIPv6SocketJoinIPv4Group()) - throw new IllegalArgumentException("Group is not IPv4 multicast address"); + throw new IllegalArgumentException("IPv6 socket cannot join IPv4 multicast group"); } else if (group instanceof Inet6Address) { if (family != StandardProtocolFamily.INET6) - throw new IllegalArgumentException("Group is not IPv6 multicast address"); + throw new IllegalArgumentException("Only IPv6 sockets can join IPv6 multicast group"); } else { throw new IllegalArgumentException("Address type not supported"); }
--- a/src/share/classes/sun/nio/ch/IOUtil.java Mon Apr 04 11:55:05 2011 -0700 +++ b/src/share/classes/sun/nio/ch/IOUtil.java Wed Apr 06 20:51:55 2011 +0100 @@ -50,9 +50,8 @@ int lim = src.limit(); assert (pos <= lim); int rem = (pos <= lim ? lim - pos : 0); - ByteBuffer bb = null; + ByteBuffer bb = Util.getTemporaryDirectBuffer(rem); try { - bb = Util.getTemporaryDirectBuffer(rem); bb.put(src); bb.flip(); // Do not update src until we see how many bytes were written @@ -187,9 +186,8 @@ return readIntoNativeBuffer(fd, dst, position, nd, lock); // Substitute a native buffer - ByteBuffer bb = null; + ByteBuffer bb = Util.getTemporaryDirectBuffer(dst.remaining()); try { - bb = Util.getTemporaryDirectBuffer(dst.remaining()); int n = readIntoNativeBuffer(fd, bb, position, nd, lock); bb.flip(); if (n > 0)