--- a/src/java.base/share/classes/java/net/DatagramSocket.java Wed May 29 08:21:33 2019 -0400
+++ b/src/java.base/share/classes/java/net/DatagramSocket.java Wed May 29 13:58:05 2019 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -29,6 +29,7 @@
import java.nio.channels.DatagramChannel;
import java.security.AccessController;
import java.security.PrivilegedExceptionAction;
+import java.util.Objects;
import java.util.Set;
import java.util.Collections;
@@ -1343,6 +1344,9 @@
public <T> DatagramSocket 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;
}
@@ -1371,6 +1375,9 @@
* @since 9
*/
public <T> T getOption(SocketOption<T> name) throws IOException {
+ Objects.requireNonNull(name);
+ if (isClosed())
+ throw new SocketException("Socket is closed");
return getImpl().getOption(name);
}