# HG changeset patch # User coffeys # Date 1412351525 -3600 # Node ID ac3e9cfecb0fc1b94c60678ae438e4b63bd3e095 # Parent bc74fab441beef9b5bebdc13fb487d5ce91fbe01 8046588: test for SO_FLOW_SLA availability does not check for EACCESS 8047187: Test jdk/net/Sockets/Test.java fails to compile after fix JDK-8046588 Reviewed-by: chegar diff -r bc74fab441be -r ac3e9cfecb0f src/solaris/native/java/net/ExtendedOptionsImpl.c --- a/src/solaris/native/java/net/ExtendedOptionsImpl.c Tue Jan 14 06:41:10 2014 -0800 +++ b/src/solaris/native/java/net/ExtendedOptionsImpl.c Fri Oct 03 16:52:05 2014 +0100 @@ -215,6 +215,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"); @@ -247,6 +250,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"); diff -r bc74fab441be -r ac3e9cfecb0f test/jdk/net/Sockets/Test.java --- a/test/jdk/net/Sockets/Test.java Tue Jan 14 06:41:10 2014 -0800 +++ b/test/jdk/net/Sockets/Test.java Fri Oct 03 16:52:05 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 { @@ -77,6 +79,16 @@ DatagramSocket dg = new DatagramSocket(0); udp_port = dg.getLocalPort(); + // If option not available, end test + Set> options = Sockets.supportedOptions( + DatagramSocket.class + ); + + if (!options.contains(ExtendedSocketOptions.SO_FLOW_SLA)) { + System.out.println("SO_FLOW_SLA not supported"); + return; + } + s = new Socket("127.0.0.1", tcp_port); sc = SocketChannel.open(); sc.connect (new InetSocketAddress("127.0.0.1", tcp_port)); @@ -125,7 +137,14 @@ 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); + } } static void doTest2() throws Exception { @@ -138,7 +157,14 @@ 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); + } } static void doTest3() throws Exception { @@ -151,7 +177,14 @@ 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); + } } static void doTest4() throws Exception { @@ -164,7 +197,14 @@ 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); + } } static void doTest5() throws Exception { @@ -179,7 +219,14 @@ 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); + } } static void doTest6() throws Exception { @@ -195,7 +242,14 @@ 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); + } } static void doTest7() throws Exception { @@ -210,7 +264,14 @@ 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); + } } static void doTest8() throws Exception { @@ -226,6 +287,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); + } } }