Skip to content

Commit 51a0e89

Browse files
committed
Fix jetty auto-start when port is -1
Signed-off-by: Doğaç Eldenk <dogac@carbonhealth.com>
1 parent 207c8f5 commit 51a0e89

File tree

1 file changed

+13
-14
lines changed
  • spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/jetty

1 file changed

+13
-14
lines changed

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/jetty/JettyWebServer.java

+13-14
Original file line numberDiff line numberDiff line change
@@ -145,24 +145,23 @@ public void start() throws WebServerException {
145145
return;
146146
}
147147
this.server.setConnectors(this.connectors);
148-
if (!this.autoStart) {
149-
return;
150-
}
151148
try {
152149
this.server.start();
153-
for (Handler handler : this.server.getHandlers()) {
154-
handleDeferredInitialize(handler);
155-
}
156-
Connector[] connectors = this.server.getConnectors();
157-
for (Connector connector : connectors) {
158-
try {
159-
connector.start();
150+
if (this.autoStart) {
151+
for (Handler handler : this.server.getHandlers()) {
152+
handleDeferredInitialize(handler);
160153
}
161-
catch (IOException ex) {
162-
if (connector instanceof NetworkConnector networkConnector) {
163-
PortInUseException.throwIfPortBindingException(ex, networkConnector::getPort);
154+
Connector[] connectors = this.server.getConnectors();
155+
for (Connector connector : connectors) {
156+
try {
157+
connector.start();
158+
}
159+
catch (IOException ex) {
160+
if (connector instanceof NetworkConnector networkConnector) {
161+
PortInUseException.throwIfPortBindingException(ex, networkConnector::getPort);
162+
}
163+
throw ex;
164164
}
165-
throw ex;
166165
}
167166
}
168167
this.started = true;

0 commit comments

Comments
 (0)