mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
8222829: DatagramSocket.setSoTimeout does not specify IAE when timeout is negative
Clarifies behaviour of setSoTimeout() method when given negative timeout value. Reviewed-by: alanb, chegar, dfuchs
This commit is contained in:
parent
ee87f2a7a4
commit
dcceed10b6
2 changed files with 45 additions and 18 deletions
|
@ -899,12 +899,15 @@ class DatagramSocket implements java.io.Closeable {
|
|||
*
|
||||
* @param timeout the specified timeout in milliseconds.
|
||||
* @throws SocketException if there is an error in the underlying protocol, such as an UDP 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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue