ADDITIONAL SYSTEM INFORMATION :
OS: CentOS7
java: java version "1.8.0_181"
A DESCRIPTION OF THE PROBLEM :
When bind a socket failed, for example, "java.net.BindException: Address already in use". I expect the jvm not open a file descriptor. But it does open a file descriptor.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Compile the source code below, and run it.
2. Identify the java process id.
3. Use `lsof` to see the opened files of the java program.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
No record of the socket file descriptor.
ACTUAL -
Has an record of the socket file descriptor.
---------- BEGIN SOURCE ----------
import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.SocketAddress;
public class Main {
public static void main(String[] args) throws Exception {
Socket s = new Socket();
// bind an already in use port.
SocketAddress addr = new InetSocketAddress("127.0.0.1", 6010);
try {
s.bind(addr);
} catch (Exception e) {
e.printStackTrace();
}
Thread.sleep(Long.MAX_VALUE);
}
}
---------- END SOURCE ----------
FREQUENCY : always
OS: CentOS7
java: java version "1.8.0_181"
A DESCRIPTION OF THE PROBLEM :
When bind a socket failed, for example, "java.net.BindException: Address already in use". I expect the jvm not open a file descriptor. But it does open a file descriptor.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Compile the source code below, and run it.
2. Identify the java process id.
3. Use `lsof` to see the opened files of the java program.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
No record of the socket file descriptor.
ACTUAL -
Has an record of the socket file descriptor.
---------- BEGIN SOURCE ----------
import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.SocketAddress;
public class Main {
public static void main(String[] args) throws Exception {
Socket s = new Socket();
// bind an already in use port.
SocketAddress addr = new InetSocketAddress("127.0.0.1", 6010);
try {
s.bind(addr);
} catch (Exception e) {
e.printStackTrace();
}
Thread.sleep(Long.MAX_VALUE);
}
}
---------- END SOURCE ----------
FREQUENCY : always