int port = serverSocket.getLocalPort();
//workaround for linux : calling close() immediately after opening socket
//may result that socket is not closed
synchronized(serverSocket) {
try {
serverSocket.wait(1);
}
catch (InterruptedException e) {
LOG.error(e);
}
}