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



##########
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:
       Correct. But the outer try/catch(IOException) is for initializing the 
Multicastsocket object ......the failure should rarely happen. I don't think we 
need to handle this for now.  I'm thinkg to throw exception, (like our 
servicecomb init task)...instead of the just logging.
   
   throw new IllegalStateException("Zero-Config init failed.", e);




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