src/java.base/share/classes/java/net/ServerSocket.java
changeset 54289 6183f835b9b6
parent 54155 b5a73f22b2bd
child 54689 b28b7f631301
child 57293 67c102efba4b
--- a/src/java.base/share/classes/java/net/ServerSocket.java	Tue Mar 26 09:24:01 2019 -0700
+++ b/src/java.base/share/classes/java/net/ServerSocket.java	Tue Mar 26 17:02:11 2019 +0000
@@ -749,14 +749,17 @@
      * timeout must be {@code > 0}.
      * A timeout of zero is interpreted as an infinite timeout.
      * @param timeout the specified timeout, in milliseconds
-     * @exception SocketException if there is an error in
-     * the underlying protocol, such as a TCP error.
+     * @throws  SocketException if there is an error in the underlying protocol,
+     *          such as a TCP error
+     * @throws  IllegalArgumentException  if {@code timeout} is negative
      * @since   1.1
      * @see #getSoTimeout()
      */
     public synchronized void setSoTimeout(int timeout) throws SocketException {
         if (isClosed())
             throw new SocketException("Socket is closed");
+        if (timeout < 0)
+            throw new IllegalArgumentException("timeout < 0");
         getImpl().setOption(SocketOptions.SO_TIMEOUT, timeout);
     }