What do you think about using `ServerSocket` to get an available port.
Something like:
```
public static int getAvailablePort(int min, int max) {
for (int i = min; i <= max; i++) {
try (ServerSocket socket = new ServerSocket(i)) {
return socket.getLocalPort();
} catch (Exception e) {
System.err.println("Port " + i + " not available, trying next
one");
continue; // try next port
}
}
throw new IllegalStateException("Can't find available network ports");
}
```
It would create more robust tests, whatever ports are taken on the machine.
Thoughts ?
[ Full content available at: https://github.com/apache/camel/pull/2549 ]
This message was relayed via gitbox.apache.org for [email protected]