Skip to content

Commit dbea25f

Browse files
committed
Polish "Log context path at startup"
Closes gh-10544
1 parent f76479f commit dbea25f

File tree

4 files changed

+12
-3
lines changed

4 files changed

+12
-3
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ public void start() throws WebServerException {
156156
this.started = true;
157157
JettyWebServer.logger
158158
.info("Jetty started on port(s) " + getActualPortsDescription()
159-
+ " with context path " + getContextPath());
159+
+ " with context path '" + getContextPath() + "'");
160160
}
161161
catch (WebServerException ex) {
162162
throw ex;

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/tomcat/TomcatWebServer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ public void start() throws WebServerException {
195195
this.started = true;
196196
TomcatWebServer.logger
197197
.info("Tomcat started on port(s): " + getPortsDescription(true)
198-
+ " with context path " + getContextPath());
198+
+ " with context path '" + getContextPath() + "'");
199199
}
200200
catch (ConnectorStartFailedException ex) {
201201
stopSilently();

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowServletWebServer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ public void start() throws WebServerException {
158158
this.started = true;
159159
UndertowServletWebServer.logger
160160
.info("Undertow started on port(s) " + getPortsDescription()
161-
+ " with context path " + this.contextPath);
161+
+ " with context path '" + this.contextPath + "'");
162162
}
163163
catch (Exception ex) {
164164
try {

spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/server/AbstractServletWebServerFactoryTests.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,15 @@ public void specificContextRoot() throws Exception {
263263
assertThat(getResponse(getLocalUrl("/say/hello"))).isEqualTo("Hello World");
264264
}
265265

266+
@Test
267+
public void contextPathIsLoggedOnStartup() {
268+
AbstractServletWebServerFactory factory = getFactory();
269+
factory.setContextPath("/custom");
270+
this.webServer = factory.getWebServer(exampleServletRegistration());
271+
this.webServer.start();
272+
assertThat(this.output.toString()).containsOnlyOnce("with context path '/custom'");
273+
}
274+
266275
@Test
267276
public void contextPathMustStartWithSlash() throws Exception {
268277
this.thrown.expect(IllegalArgumentException.class);

0 commit comments

Comments
 (0)