8046588: test for SO_FLOW_SLA availability does not check for EACCESS
Reviewed-by: alanb, chegar
--- a/jdk/src/solaris/native/java/net/ExtendedOptionsImpl.c Thu Jun 12 10:32:19 2014 +0200
+++ b/jdk/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/jdk/test/jdk/net/Sockets/Test.java Thu Jun 12 10:32:19 2014 +0200
+++ b/jdk/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);
+ }
}
}