elecharny commented on PR #74:
URL: https://github.com/apache/mina/pull/74#issuecomment-5947233826
FTR, there is something fishy.
The original code was:
```
acceptor.setCloseOnDeactivation(false);
acceptor.setReuseAddress(true);
acceptor.setHandler(new IoHandlerAdapter());
try {
int port = AvailablePortFinder.getNextAvailable(1025);
InetSocketAddress address = new InetSocketAddress("127.0.0.1",
port);
acceptor.bind(address);
acceptor.unbind(address);
acceptor.bind(address);
acceptor.unbind(address);
} finally {
acceptor.dispose();
}
```
I changed it to be:
```
acceptor.setCloseOnDeactivation(false);
acceptor.setReuseAddress(true);
acceptor.setHandler(new IoHandlerAdapter());
try {
int port = AcceptorBindUtil.tryBind(acceptor);
InetSocketAddress address = new InetSocketAddress("127.0.0.1",
port);
acceptor.unbind(address);
acceptor.bind(address);
acceptor.unbind(address);
} finally {
acceptor.dispose();
}
```
The only difference is that the `AcceptorBindUtil.tryBind(acceptor)` call
was binding the acceptor to an address that has nothing to do with
`InetSocketAddress("127.0.0.1", port)` (actually, the used address was
[0:0:0:0:0:0:0:0]:<port>).
I suggest a modification of the `AcceptorBindUtil.tryBind()` method to add
an optional host parameter, so the test would be:
```
acceptor.setCloseOnDeactivation(false);
acceptor.setReuseAddress(true);
acceptor.setHandler(new IoHandlerAdapter());
try {
int port = AcceptorBindUtil.tryBind(acceptor, "127.0.0.1");
InetSocketAddress address = acceptor.getLocalAddress();
acceptor.unbind(address);
acceptor.bind(address);
acceptor.unbind(address);
} finally {
acceptor.dispose();
}
```
wdyt?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]