mirror of
https://github.com/openjdk/jdk.git
synced 2026-03-06 14:10:36 +00:00
8046588: test for SO_FLOW_SLA availability does not check for EACCESS
Reviewed-by: alanb, chegar
This commit is contained in:
parent
df614caef8
commit
7ab2a6410b
@ -218,6 +218,9 @@ JNIEXPORT void JNICALL Java_sun_net_ExtendedOptionsImpl_setFlowOption
|
||||
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 @@ JNIEXPORT void JNICALL Java_sun_net_ExtendedOptionsImpl_getFlowOption
|
||||
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");
|
||||
|
||||
@ -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 @@ public class Test {
|
||||
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 @@ public class Test {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user