From 7c0ccdf78cb599ad016831c83b6a6ccb630c1773 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Thu, 4 Aug 2022 11:45:39 +0100 Subject: [PATCH] Log allocated port when Livereload server is using an ephemeral port Closes gh-31983 --- .../devtools/autoconfigure/OptionalLiveReloadServer.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/autoconfigure/OptionalLiveReloadServer.java b/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/autoconfigure/OptionalLiveReloadServer.java index 1ce4ea5bc8..42ab7ac3e7 100644 --- a/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/autoconfigure/OptionalLiveReloadServer.java +++ b/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/autoconfigure/OptionalLiveReloadServer.java @@ -52,10 +52,11 @@ public class OptionalLiveReloadServer implements InitializingBean { void startServer() { if (this.server != null) { try { + int port = this.server.getPort(); if (!this.server.isStarted()) { - this.server.start(); + port = this.server.start(); } - logger.info(LogMessage.format("LiveReload server is running on port %s", this.server.getPort())); + logger.info(LogMessage.format("LiveReload server is running on port %s", port)); } catch (Exception ex) { logger.warn("Unable to start LiveReload server");