- 
    Bug 
- 
    Resolution: Fixed
- 
     P3 P3
- 
    1.3.0
- 
        ladybird
- 
        x86, sparc
- 
        solaris_2.6, windows_2000
| Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build | 
|---|---|---|---|---|---|---|
| JDK-2033100 | 1.4.0 | Jean-Christophe Collet | P3 | Closed | Fixed | beta | 
Name: dfC67450 Date: 03/30/2000
Javadoc for java.net.Socket.setReceiveBufferSize(size) states:
* @exception IllegalArgumentException if the value is 0 or is
* negative.
But method throws SocketException instead of IllegalArgumentException and throws
IllegalArgumentException only if negative size passed.
Source for java.net.Socket:
public synchronized void setReceiveBufferSize(int size)
throws SocketException{
if (size < 0) {
throw new IllegalArgumentException("invalid receive size");
}
impl.setOption(SocketOptions.SO_RCVBUF, new Integer(size));
}
Here is the test demonstrating the bug:
---------------------------------------------
import java.net.*;
import java.io.*;
public class TestIAE {
public static void main (String args[]){
try {
ServerSocket server = new ServerSocket(0);
int port = server.getLocalPort();
InetAddress address = server.getInetAddress();
Socket soc = new Socket(address, port);
try {
soc.setReceiveBufferSize(0);
} catch (IllegalArgumentException iae) {
soc.close();
server.close();
System.out.println("Test passed");
return;
}
System.out.println("No exceptions");
} catch (Exception e) {
System.out.println(" " + e);
}
System.out.println(" Test failed");
}
}
------------- output from the test ---------
java.net.SocketException: bad parameter for SO_SNDBUF or SO_RCVBUF
Test failed
---------------------------------------------
======================================================================
- backported by
- 
                    JDK-2033100 java.net.Socket.setReceiveBufferSize(size) does not throw IAE with 0 -           
- Closed
 
-         
- duplicates
- 
                    JDK-4355745 setReceiveBufferSize(int s)in Socket will not throw an IllegalArgumentException -           
- Closed
 
-