changeset 10079:431cce1509b5

8046588: test for SO_FLOW_SLA availability does not check for EACCESS Reviewed-by: alanb, chegar
author michaelm
date Fri, 13 Jun 2014 14:30:41 +0100
parents 81e22723ba57
children 22fd62cbfe82
files src/solaris/native/java/net/ExtendedOptionsImpl.c test/jdk/net/Sockets/Test.java
diffstat 2 files changed, 23 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/solaris/native/java/net/ExtendedOptionsImpl.c	Thu Jun 12 10:32:19 2014 +0200
+++ b/src/solaris/native/java/net/ExtendedOptionsImpl.c	Fri Jun 13 14:30:41 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/test/jdk/net/Sockets/Test.java	Thu Jun 12 10:32:19 2014 +0200
+++ b/test/jdk/net/Sockets/Test.java	Fri Jun 13 14:30:41 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);
+        }
     }
 }