liubao68 commented on a change in pull request #1827:
URL: 
https://github.com/apache/servicecomb-java-chassis/pull/1827#discussion_r438479863



##########
File path: 
service-registry/registry-zero-config/src/main/java/org/apache/servicecomb/zeroconfig/server/ServerUtil.java
##########
@@ -172,16 +172,29 @@ private static ServerMicroserviceInstance 
buildServerMicroserviceInstanceFromMap
     return map;
   }
 
+  private static void initMulticastSocket() throws IOException{
+    multicastSocket = new MulticastSocket(PORT);
+    group = InetAddress.getByName(GROUP);
+    multicastSocket.joinGroup(group); // need to join the group to be able to 
receive the data
+  }
+
   private static void startListenerForRegisterUnregisterEvent() {
     try {
       byte[] buffer = new byte[DATA_PACKET_BUFFER_SIZE];
-      multicastSocket = new MulticastSocket(PORT);
-      group = InetAddress.getByName(GROUP);
-      multicastSocket.joinGroup(group); // need to join the group to be able 
to receive the data
-
+      initMulticastSocket();
       while (true) {
         DatagramPacket receivePacketBuffer = new DatagramPacket(buffer, 
buffer.length);
-        multicastSocket.receive(receivePacketBuffer);
+        try {

Review comment:
       Maybe need look at the outer `try', if `IOException` is thrown, the tast 
is exit. 




----------------------------------------------------------------
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.

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


Reply via email to