Does the method RepUtils.openSocketChannel(xxx) have an FD leak under certain scenarios such as heavy packet loss?Could we add exception handling when creating the socket object, and close the channel immediately if creation fails?
` public static SocketChannel openSocketChannel(InetSocketAddress addr,
InetSocketAddress localAddr,
ConnectOptions connectOpts)
throws IOException {
assert TestHookExecute.doHookIfSet(openSocketChannelHook, connectOpts);
final SocketChannel channel = SocketChannel.open();
final boolean blocking = connectOpts.getBlocking();
channel.configureBlocking(blocking);
final Socket socket = channel.socket();
if (connectOpts.getReceiveBufferSize() != 0) {
socket.setReceiveBufferSize(connectOpts.getReceiveBufferSize());
}
socket.setTcpNoDelay(connectOpts.getTcpNoDelay());
socket.setSoTimeout(connectOpts.getReadTimeout());
socket.setReuseAddress(connectOpts.getReuseAddr());
InetSocketAddress bindAddr = connectOpts.getBindAnyLocalAddr() ? null : localAddr;
socket.bind(bindAddr);
if (blocking) {
socket.connect(addr, connectOpts.getOpenTimeout());
} else {
channel.connect(addr); // TODO Add logic to close the channel when a channel exception occurs.
}
return channel;
}`
Does the method RepUtils.openSocketChannel(xxx) have an FD leak under certain scenarios such as heavy packet loss?Could we add exception handling when creating the socket object, and close the channel immediately if creation fails?
` public static SocketChannel openSocketChannel(InetSocketAddress addr,
InetSocketAddress localAddr,
ConnectOptions connectOpts)
throws IOException {