changeset 4906:6f7d14fd7d8f

7132679: (dc) DatagramChannel.send fails with ECONNREFUSED when not connected (Mac OSX) Reviewed-by: michaelm
author alanb
date Mon, 30 Jan 2012 13:43:46 +0000
parents 63b6953bbcfa
children d476c80173a3
files src/share/classes/sun/nio/ch/DatagramChannelImpl.java
diffstat 1 files changed, 8 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/sun/nio/ch/DatagramChannelImpl.java	Mon Jan 30 13:40:20 2012 +0000
+++ b/src/share/classes/sun/nio/ch/DatagramChannelImpl.java	Mon Jan 30 13:43:46 2012 +0000
@@ -509,8 +509,15 @@
         int rem = (pos <= lim ? lim - pos : 0);
 
         boolean preferIPv6 = (family != StandardProtocolFamily.INET);
-        int written = send0(preferIPv6, fd, ((DirectBuffer)bb).address() + pos,
+        int written;
+        try {
+            written = send0(preferIPv6, fd, ((DirectBuffer)bb).address() + pos,
                             rem, target);
+        } catch (PortUnreachableException pue) {
+            if (isConnected())
+                throw pue;
+            written = rem;
+        }
         if (written > 0)
             bb.position(pos + written);
         return written;