Skip to content

Commit 8c37ad7

Browse files
committed
Startup/shutdown log messages for AbstractHttpServer
Issue: SPR-16494
1 parent 37609e4 commit 8c37ad7

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

spring-web/src/test/java/org/springframework/http/server/reactive/bootstrap/AbstractHttpServer.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,21 @@
1919
import java.util.LinkedHashMap;
2020
import java.util.Map;
2121

22+
import org.apache.commons.logging.Log;
23+
import org.apache.commons.logging.LogFactory;
24+
2225
import org.springframework.http.server.reactive.ContextPathCompositeHandler;
2326
import org.springframework.http.server.reactive.HttpHandler;
2427
import org.springframework.util.Assert;
28+
import org.springframework.util.StopWatch;
2529

2630
/**
2731
* @author Rossen Stoyanchev
2832
*/
2933
public abstract class AbstractHttpServer implements HttpServer {
3034

35+
protected Log logger = LogFactory.getLog(getClass().getName());
36+
3137
private String host = "0.0.0.0";
3238

3339
private int port = 0;
@@ -116,9 +122,15 @@ public boolean isRunning() {
116122
public final void start() {
117123
synchronized (this.lifecycleMonitor) {
118124
if (!isRunning()) {
125+
String serverName = getClass().getSimpleName();
126+
logger.debug("Starting " + serverName + "...");
119127
this.running = true;
120128
try {
129+
StopWatch stopWatch = new StopWatch();
130+
stopWatch.start();
121131
startInternal();
132+
long millis = stopWatch.getTotalTimeMillis();
133+
logger.debug("Server started on port " + getPort() + "(" + millis + " millis).");
122134
}
123135
catch (Throwable ex) {
124136
throw new IllegalStateException(ex);
@@ -134,9 +146,14 @@ public final void start() {
134146
public final void stop() {
135147
synchronized (this.lifecycleMonitor) {
136148
if (isRunning()) {
149+
String serverName = getClass().getSimpleName();
150+
logger.debug("Stopping " + serverName + "...");
137151
this.running = false;
138152
try {
153+
StopWatch stopWatch = new StopWatch();
154+
stopWatch.start();
139155
stopInternal();
156+
logger.debug("Server stopped (" + stopWatch.getTotalTimeMillis() + " millis).");
140157
}
141158
catch (Throwable ex) {
142159
throw new IllegalStateException(ex);

0 commit comments

Comments
 (0)