提交 df487187 编写于 作者: M mfang

Merge

...@@ -215,6 +215,9 @@ JNIEXPORT void JNICALL Java_sun_net_ExtendedOptionsImpl_setFlowOption ...@@ -215,6 +215,9 @@ JNIEXPORT void JNICALL Java_sun_net_ExtendedOptionsImpl_setFlowOption
if (errno == ENOPROTOOPT) { if (errno == ENOPROTOOPT) {
JNU_ThrowByName(env, "java/lang/UnsupportedOperationException", JNU_ThrowByName(env, "java/lang/UnsupportedOperationException",
"unsupported socket option"); "unsupported socket option");
} else if (errno == EACCES || errno == EPERM) {
NET_ERROR(env, JNU_JAVANETPKG "SocketException",
"Permission denied");
} else { } else {
NET_ERROR(env, JNU_JAVANETPKG "SocketException", NET_ERROR(env, JNU_JAVANETPKG "SocketException",
"set option SO_FLOW_SLA failed"); "set option SO_FLOW_SLA failed");
...@@ -247,6 +250,9 @@ JNIEXPORT void JNICALL Java_sun_net_ExtendedOptionsImpl_getFlowOption ...@@ -247,6 +250,9 @@ JNIEXPORT void JNICALL Java_sun_net_ExtendedOptionsImpl_getFlowOption
if (errno == ENOPROTOOPT) { if (errno == ENOPROTOOPT) {
JNU_ThrowByName(env, "java/lang/UnsupportedOperationException", JNU_ThrowByName(env, "java/lang/UnsupportedOperationException",
"unsupported socket option"); "unsupported socket option");
} else if (errno == EACCES || errno == EPERM) {
NET_ERROR(env, JNU_JAVANETPKG "SocketException",
"Permission denied");
} else { } else {
NET_ERROR(env, JNU_JAVANETPKG "SocketException", NET_ERROR(env, JNU_JAVANETPKG "SocketException",
"set option SO_FLOW_SLA failed"); "set option SO_FLOW_SLA failed");
......
...@@ -30,8 +30,10 @@ ...@@ -30,8 +30,10 @@
*/ */
import java.net.*; import java.net.*;
import java.io.IOException;
import java.nio.channels.*; import java.nio.channels.*;
import java.util.concurrent.*; import java.util.concurrent.*;
import java.util.Set;
import jdk.net.*; import jdk.net.*;
public class Test { public class Test {
...@@ -75,6 +77,13 @@ public class Test { ...@@ -75,6 +77,13 @@ public class Test {
DatagramSocket dg = new DatagramSocket(0); DatagramSocket dg = new DatagramSocket(0);
final int udp_port = dg.getLocalPort(); 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 Socket s = new Socket("127.0.0.1", tcp_port);
final SocketChannel sc = SocketChannel.open(); final SocketChannel sc = SocketChannel.open();
sc.connect (new InetSocketAddress("127.0.0.1", tcp_port)); sc.connect (new InetSocketAddress("127.0.0.1", tcp_port));
...@@ -149,6 +158,13 @@ public class Test { ...@@ -149,6 +158,13 @@ public class Test {
if (success) { if (success) {
throw new RuntimeException("Test failed"); 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);
}
} }
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册