--- a/src/java.base/share/classes/sun/nio/ch/NioSocketImpl.java Thu May 23 11:07:37 2019 +0100
+++ b/src/java.base/share/classes/sun/nio/ch/NioSocketImpl.java Thu May 23 12:10:48 2019 +0100
@@ -953,6 +953,8 @@
protected <T> void setOption(SocketOption<T> opt, T value) throws IOException {
if (!supportedOptions().contains(opt))
throw new UnsupportedOperationException("'" + opt + "' not supported");
+ if (!opt.type().isInstance(value))
+ throw new IllegalArgumentException("Invalid value '" + value + "'");
synchronized (stateLock) {
ensureOpen();
if (opt == StandardSocketOptions.IP_TOS) {