< prev index next >

src/java.base/share/classes/java/net/DatagramSocket.java

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 1995, 2015, 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 * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this --- 1,7 ---- /* ! * 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 * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this
*** 27,36 **** --- 27,37 ---- import java.io.IOException; 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; /** * This class represents a socket for sending and receiving datagram packets.
*** 1341,1350 **** --- 1342,1354 ---- * @since 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; } /**
*** 1369,1378 **** --- 1373,1385 ---- * do not require any security permission. * * @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); } private static Set<SocketOption<?>> options; private static boolean optionsSet = false;
< prev index next >