--- a/jdk/src/java.base/unix/classes/java/net/PlainSocketImpl.java Wed Apr 27 12:06:51 2016 -0700
+++ b/jdk/src/java.base/unix/classes/java/net/PlainSocketImpl.java Wed Apr 27 20:36:02 2016 +0100
@@ -28,10 +28,7 @@
import java.io.FileDescriptor;
import java.util.Set;
import java.util.HashSet;
-import java.util.Collections;
-import jdk.net.*;
-
-import static sun.net.ExtendedOptionsImpl.*;
+import sun.net.ext.ExtendedSocketOptions;
/*
* On Unix systems we simply delegate to native methods.
@@ -57,8 +54,11 @@
this.fd = fd;
}
+ static final ExtendedSocketOptions extendedOptions =
+ ExtendedSocketOptions.getInstance();
+
protected <T> void setOption(SocketOption<T> name, T value) throws IOException {
- if (!name.equals(ExtendedSocketOptions.SO_FLOW_SLA)) {
+ if (!extendedOptions.isOptionSupported(name)) {
if (!name.equals(StandardSocketOptions.SO_REUSEPORT)) {
super.setOption(name, value);
} else {
@@ -69,21 +69,19 @@
}
}
} else {
- if (getSocket() == null || !flowSupported()) {
+ if (getSocket() == null) {
throw new UnsupportedOperationException("unsupported option");
}
if (isClosedOrPending()) {
throw new SocketException("Socket closed");
}
- checkSetOptionPermission(name);
- checkValueType(value, SocketFlow.class);
- setFlowOption(getFileDescriptor(), (SocketFlow)value);
+ extendedOptions.setOption(fd, name, value);
}
}
@SuppressWarnings("unchecked")
protected <T> T getOption(SocketOption<T> name) throws IOException {
- if (!name.equals(ExtendedSocketOptions.SO_FLOW_SLA)) {
+ if (!extendedOptions.isOptionSupported(name)) {
if (!name.equals(StandardSocketOptions.SO_REUSEPORT)) {
return super.getOption(name);
} else {
@@ -93,31 +91,28 @@
throw new UnsupportedOperationException("unsupported option");
}
}
- }
- if (getSocket() == null || !flowSupported()) {
- throw new UnsupportedOperationException("unsupported option");
+ } else {
+ if (getSocket() == null) {
+ throw new UnsupportedOperationException("unsupported option");
+ }
+ if (isClosedOrPending()) {
+ throw new SocketException("Socket closed");
+ }
+ return (T) extendedOptions.getOption(fd, name);
}
- if (isClosedOrPending()) {
- throw new SocketException("Socket closed");
- }
- checkGetOptionPermission(name);
- SocketFlow flow = SocketFlow.create();
- getFlowOption(getFileDescriptor(), flow);
- return (T)flow;
}
protected Set<SocketOption<?>> supportedOptions() {
- HashSet<SocketOption<?>> options = new HashSet<>(
- super.supportedOptions());
-
- if (getSocket() != null && flowSupported()) {
- options.add(ExtendedSocketOptions.SO_FLOW_SLA);
+ HashSet<SocketOption<?>> options = new HashSet<>(super.supportedOptions());
+ if (getSocket() != null) {
+ options.addAll(extendedOptions.options());
}
return options;
}
protected void socketSetOption(int opt, boolean b, Object val) throws SocketException {
- if (opt == SocketOptions.SO_REUSEPORT && !supportedOptions().contains(StandardSocketOptions.SO_REUSEPORT)) {
+ if (opt == SocketOptions.SO_REUSEPORT &&
+ !supportedOptions().contains(StandardSocketOptions.SO_REUSEPORT)) {
throw new UnsupportedOperationException("unsupported option");
}
try {