This commit is contained in:
Vedran Pavic
2019-07-02 19:23:00 +02:00
parent 1ca9daccb4
commit 8cb85618c2
8 changed files with 18 additions and 27 deletions

View File

@@ -71,21 +71,12 @@ public class Initializer implements ServletContextListener {
}
private static int getAvailablePort() {
ServerSocket socket = null;
try {
socket = new ServerSocket(0);
try (ServerSocket socket = new ServerSocket(0)) {
return socket.getLocalPort();
}
catch (IOException ex) {
throw new RuntimeException(ex);
}
finally {
try {
socket.close();
}
catch (IOException ex) {
}
}
}
}