|
|
|
@ -113,7 +113,7 @@ public class ServerProperties implements EmbeddedServletContainerCustomizer {
|
|
|
|
|
public void customize(ConfigurableEmbeddedServletContainerFactory factory) {
|
|
|
|
|
Integer port = getPort();
|
|
|
|
|
if (this.scan) {
|
|
|
|
|
port = SocketUtils.findAvailableTcpPort(port != null ? 8080 : port);
|
|
|
|
|
port = scanForPort(port);
|
|
|
|
|
}
|
|
|
|
|
if (port != null) {
|
|
|
|
|
factory.setPort(port);
|
|
|
|
@ -132,6 +132,26 @@ public class ServerProperties implements EmbeddedServletContainerCustomizer {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Integer scanForPort(Integer port) {
|
|
|
|
|
boolean found = false;
|
|
|
|
|
int delta = 1;
|
|
|
|
|
port = port == null ? 8080 : port;
|
|
|
|
|
while (!found) {
|
|
|
|
|
try {
|
|
|
|
|
port = SocketUtils.findAvailableTcpPort(port, port + delta);
|
|
|
|
|
found = true;
|
|
|
|
|
}
|
|
|
|
|
catch (IllegalStateException e) {
|
|
|
|
|
if (delta > 65536) {
|
|
|
|
|
throw e;
|
|
|
|
|
}
|
|
|
|
|
delta = delta > 5 ? delta > 100 ? delta * 4 : delta * 3 : delta * 2;
|
|
|
|
|
}
|
|
|
|
|
port = port + delta;
|
|
|
|
|
}
|
|
|
|
|
return port;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static class Tomcat {
|
|
|
|
|
|
|
|
|
|
private String accessLogPattern;
|
|
|
|
|