Filter WebServerInitializedEvent for web-only. (#3514)

Filter WebServerInitializedEvent for web-only, excluding management.

Fixes gh-2732
This commit is contained in:
Chris White
2019-06-05 11:35:49 -07:00
committed by Spencer Gibb
parent 066ffa3fea
commit 4145df96dc

View File

@@ -119,11 +119,14 @@ public class EurekaAutoServiceRegistration implements AutoServiceRegistration, S
@EventListener(WebServerInitializedEvent.class)
public void onApplicationEvent(WebServerInitializedEvent event) {
// TODO: take SSL into account
int localPort = event.getWebServer().getPort();
if (this.port.get() == 0) {
log.info("Updating port to " + localPort);
this.port.compareAndSet(0, localPort);
start();
String contextName = event.getApplicationContext().getServerNamespace();
if (contextName == null || !contextName.equals("management")) {
int localPort = event.getWebServer().getPort();
if (this.port.get() == 0) {
log.info("Updating port to " + localPort);
this.port.compareAndSet(0, localPort);
start();
}
}
}