Merge
authormichaelm
Fri, 13 Jun 2014 14:32:49 +0100
changeset 24963 654c3c8086f5
parent 24962 a6927b2a7315 (diff)
parent 24873 7553ba5f4eff (current diff)
child 24964 296ec671ea4a
child 24970 094bfaa699c3
Merge
--- a/jdk/src/solaris/native/java/net/ExtendedOptionsImpl.c	Fri Jun 13 08:25:50 2014 +0800
+++ b/jdk/src/solaris/native/java/net/ExtendedOptionsImpl.c	Fri Jun 13 14:32:49 2014 +0100
@@ -218,6 +218,9 @@
             if (errno == ENOPROTOOPT) {
                 JNU_ThrowByName(env, "java/lang/UnsupportedOperationException",
                         "unsupported socket option");
+            } else if (errno == EACCES || errno == EPERM) {
+                NET_ERROR(env, JNU_JAVANETPKG "SocketException",
+                                "Permission denied");
             } else {
                 NET_ERROR(env, JNU_JAVANETPKG "SocketException",
                                 "set option SO_FLOW_SLA failed");
@@ -251,6 +254,9 @@
             if (errno == ENOPROTOOPT) {
                 JNU_ThrowByName(env, "java/lang/UnsupportedOperationException",
                         "unsupported socket option");
+            } else if (errno == EACCES || errno == EPERM) {
+                NET_ERROR(env, JNU_JAVANETPKG "SocketException",
+                                "Permission denied");
             } else {
                 NET_ERROR(env, JNU_JAVANETPKG "SocketException",
                                 "set option SO_FLOW_SLA failed");
--- a/jdk/test/jdk/net/Sockets/Test.java	Fri Jun 13 08:25:50 2014 +0800
+++ b/jdk/test/jdk/net/Sockets/Test.java	Fri Jun 13 14:32:49 2014 +0100
@@ -30,8 +30,10 @@
  */
 
 import java.net.*;
+import java.io.IOException;
 import java.nio.channels.*;
 import java.util.concurrent.*;
+import java.util.Set;
 import jdk.net.*;
 
 public class Test {
@@ -75,6 +77,13 @@
         DatagramSocket dg = new DatagramSocket(0);
         final int udp_port = dg.getLocalPort();
 
+        // If option not available, end test
+        Set<SocketOption<?>> options = dg.supportedOptions();
+        if (!options.contains(ExtendedSocketOptions.SO_FLOW_SLA)) {
+            System.out.println("SO_FLOW_SLA not supported");
+            return;
+        }
+
         final Socket s = new Socket("127.0.0.1", tcp_port);
         final SocketChannel sc = SocketChannel.open();
         sc.connect (new InetSocketAddress("127.0.0.1", tcp_port));
@@ -125,6 +134,13 @@
             if (success) {
                 throw new RuntimeException("Test failed");
             }
-        } catch (UnsupportedOperationException e) {}
+        } catch (UnsupportedOperationException e) {
+            System.out.println (e);
+        } catch (IOException e) {
+            // Probably a permission error, but we're not
+            // going to check unless a specific permission exception
+            // is defined.
+            System.out.println (e);
+        }
     }
 }