- 
    Bug 
- 
    Resolution: Fixed
- 
     P4 P4
- 
    1.1.4
- 
        1.2beta4
- 
        sparc
- 
        solaris_2.5
- 
        Verified
Name: yyC67448 Date: 09/26/97
The java.net.Socket.setSoLinger(boolean, int) does not check its second
parameter for negative value when its first parameter is true.
Here is the test demonstrating the bug:
-------------------------------- Test.java -----------------------------
import java.net.*;
class test
{
public static void main(String args[])
{
InetAddress sin = null;
Socket soc = null;
int value = 0;
/*
* Try to get localhost address
*/
try {
sin = InetAddress.getLocalHost();
} catch(Exception e)
{
System.out.println("Can not get localhost Address:" + e);
System.exit(-1);
}
/*
* Hope Telnet service enabled on localhost
*/
try {
soc = new Socket(sin, 23, true);
} catch(Exception e)
{
System.out.println("Can not create socket:" + e);
System.exit(-1);
}
/*
* Try to set negative value
*/
try {
soc.setSoLinger(true, -20);
value = soc.getSoLinger();
} catch(IllegalArgumentException e)
{
try {
soc.close();
} catch(Exception e1)
{
System.out.println("Can not close socket:" + e1);
System.exit(-1);
}
System.out.println("OKAY");
System.exit(0);
}
catch(Exception e)
{
try {
soc.close();
} catch(Exception e1)
{
System.out.println("Can not close socket :" + e1);
System.exit(-1);
}
System.out.println("Unexpected exception:" + e);
}
try {
soc.close();
} catch(Exception e)
{
System.out.println("Can not close socket:" + e);
System.exit(-1);
}
System.out.println("No exceptions. Val = " + value);
}
}
---------------------- Output from the test -----------------
No exceptions. Val = -20
-----------------------------------------------------------------
======================================================================