8224477: java.net socket types new-style socket option methods - spec and impl mismatch

Reviewed-by: alanb
This commit is contained in:
Chris Hegarty 2019-05-29 13:58:05 +01:00
parent cf48689855
commit bc24d17e80
18 changed files with 1289 additions and 300 deletions

View file

@ -33,6 +33,7 @@ import java.lang.invoke.VarHandle;
import java.nio.channels.SocketChannel;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.Objects;
import java.util.Set;
import java.util.Collections;
@ -1786,6 +1787,9 @@ class Socket implements java.io.Closeable {
* @since 9
*/
public <T> Socket setOption(SocketOption<T> name, T value) throws IOException {
Objects.requireNonNull(name);
if (isClosed())
throw new SocketException("Socket is closed");
getImpl().setOption(name, value);
return this;
}
@ -1815,6 +1819,9 @@ class Socket implements java.io.Closeable {
*/
@SuppressWarnings("unchecked")
public <T> T getOption(SocketOption<T> name) throws IOException {
Objects.requireNonNull(name);
if (isClosed())
throw new SocketException("Socket is closed");
return getImpl().getOption(name);
}