dragon-zhang opened a new issue #2860:
URL: https://github.com/apache/incubator-shenyu/issues/2860


   ### Question
   
   In 
`org.apache.shenyu.client.springcloud.init.ContextRegisterListener#onApplicationEvent`,
 if `org.springframework.context.event.ContextRefreshedEvent` change to 
`org.springframework.boot.web.context.WebServerInitializedEvent`, we can use 
`org.springframework.boot.web.server.WebServer#getPort` to set port 
automatically, so change it ?
   ```java
       @Override
       public void onApplicationEvent(@NonNull final WebServerInitializedEvent 
webServerInitializedEvent) {
           if (!registered.compareAndSet(false, true)) {
               return;
           }
           if (Boolean.TRUE.equals(isFull)) {
               publisher.publishEvent(buildMetaDataDTO());
           }
           //Note: In this way, no matter what container is actually used,
           //you can get the port that is actually started in the end.
           int mergedPort = port <= 0 ? 
webServerInitializedEvent.getWebServer().getPort() : port;
           publisher.publishEvent(buildUriRegisterDTO(mergedPort));
       }
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to