--- old/src/java.base/share/classes/java/net/DatagramSocket.java 2019-05-27 11:33:55.109804672 +0100 +++ new/src/java.base/share/classes/java/net/DatagramSocket.java 2019-05-27 11:33:54.825804682 +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 DatagramSocket setOption(SocketOption 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 getOption(SocketOption name) throws IOException { + Objects.requireNonNull(name); + if (isClosed()) + throw new SocketException("Socket is closed"); return getImpl().getOption(name); }