You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by GitBox <gi...@apache.org> on 2020/06/09 19:05:42 UTC

[GitHub] [servicecomb-java-chassis] jungan21 opened a new pull request #1825: [SCB-1995]Fix incorrect message issue identifed through testing

jungan21 opened a new pull request #1825:
URL: https://github.com/apache/servicecomb-java-chassis/pull/1825


   Follow this checklist to help us incorporate your contribution quickly and easily:
   
    - [ ] Make sure there is a [JIRA issue](https://issues.apache.org/jira/browse/SCB) filed for the change (usually before you start working on it).  Trivial changes like typos do not require a JIRA issue.  Your pull request should address just this issue, without pulling in other changes.
    - [ ] Each commit in the pull request should have a meaningful subject line and body.
    - [ ] Format the pull request title like `[SCB-XXX] Fixes bug in ApproximateQuantiles`, where you replace `SCB-XXX` with the appropriate JIRA issue.
    - [ ] Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
    - [ ] Run `mvn clean install -Pit` to make sure basic checks pass. A more thorough check will be performed on your pull request automatically.
    - [ ] If this contribution is large, please file an Apache [Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
   
   ---
   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [servicecomb-java-chassis] coveralls edited a comment on pull request #1825: [SCB-1995]Fix incorrect message issue identifed through testing

Posted by GitBox <gi...@apache.org>.
coveralls edited a comment on pull request #1825:
URL: https://github.com/apache/servicecomb-java-chassis/pull/1825#issuecomment-641591330


   
   [![Coverage Status](https://coveralls.io/builds/31355393/badge)](https://coveralls.io/builds/31355393)
   
   Coverage increased (+0.4%) to 86.827% when pulling **c497ee142e3af48f7e38b051cad0e309505449ce on jungan21:master** into **1c4f7c61d70bdac7df6f8ab2adc0f020c1d5db73 on apache:master**.
   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [servicecomb-java-chassis] jungan21 commented on a change in pull request #1825: [SCB-1995]Fix incorrect message issue identifed through testing

Posted by GitBox <gi...@apache.org>.
jungan21 commented on a change in pull request #1825:
URL: https://github.com/apache/servicecomb-java-chassis/pull/1825#discussion_r437822660



##########
File path: service-registry/registry-zero-config/src/main/java/org/apache/servicecomb/zeroconfig/server/ServerUtil.java
##########
@@ -179,12 +179,12 @@ private static ServerMicroserviceInstance buildServerMicroserviceInstanceFromMap
 
   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
 
       while (true) {
+        byte[] buffer = new byte[DATA_PACKET_BUFFER_SIZE];
         DatagramPacket receivePacketBuffer = new DatagramPacket(buffer, buffer.length);
         multicastSocket.receive(receivePacketBuffer);
         String receivedPacketString = new String(receivePacketBuffer.getData(), ENCODE);

Review comment:
       good point. Unfortunately, based on the Multicast working mechanism, we have to create a buffer before data is received.  After data is received, then buffer is filled with the received data.   So we can't create a buffer with size exactly same as the received data.
   
   By the way, it's also mentioned in the JDK source code comments: 
   https://github.com/frohoff/jdk8u-jdk/blob/master/src/share/classes/java/net/DatagramSocket.java#L698-L700
   




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [servicecomb-java-chassis] coveralls commented on pull request #1825: [SCB-1995]Fix incorrect message issue identifed through testing

Posted by GitBox <gi...@apache.org>.
coveralls commented on pull request #1825:
URL: https://github.com/apache/servicecomb-java-chassis/pull/1825#issuecomment-641591330


   
   [![Coverage Status](https://coveralls.io/builds/31349126/badge)](https://coveralls.io/builds/31349126)
   
   Coverage increased (+0.003%) to 86.432% when pulling **b73ad72402b03002428a1896ac853485c436b6f0 on jungan21:master** into **6974534ac55a1b7f6b4e53aa79e1f6e712e93cfa on apache:master**.
   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [servicecomb-java-chassis] liubao68 commented on a change in pull request #1825: [SCB-1995]Fix incorrect message issue identifed through testing

Posted by GitBox <gi...@apache.org>.
liubao68 commented on a change in pull request #1825:
URL: https://github.com/apache/servicecomb-java-chassis/pull/1825#discussion_r437803087



##########
File path: service-registry/registry-zero-config/src/main/java/org/apache/servicecomb/zeroconfig/server/ServerUtil.java
##########
@@ -179,12 +179,12 @@ private static ServerMicroserviceInstance buildServerMicroserviceInstanceFromMap
 
   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
 
       while (true) {
+        byte[] buffer = new byte[DATA_PACKET_BUFFER_SIZE];
         DatagramPacket receivePacketBuffer = new DatagramPacket(buffer, buffer.length);
         multicastSocket.receive(receivePacketBuffer);
         String receivedPacketString = new String(receivePacketBuffer.getData(), ENCODE);

Review comment:
       This logic seams not correct. Maybe you'd check the length of data actually received and using the correct data. 




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [servicecomb-java-chassis] liubao68 commented on a change in pull request #1825: [SCB-1995]Fix incorrect message issue identifed through testing

Posted by GitBox <gi...@apache.org>.
liubao68 commented on a change in pull request #1825:
URL: https://github.com/apache/servicecomb-java-chassis/pull/1825#discussion_r437823717



##########
File path: service-registry/registry-zero-config/src/main/java/org/apache/servicecomb/zeroconfig/server/ServerUtil.java
##########
@@ -179,12 +179,12 @@ private static ServerMicroserviceInstance buildServerMicroserviceInstanceFromMap
 
   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
 
       while (true) {
+        byte[] buffer = new byte[DATA_PACKET_BUFFER_SIZE];
         DatagramPacket receivePacketBuffer = new DatagramPacket(buffer, buffer.length);
         multicastSocket.receive(receivePacketBuffer);
         String receivedPacketString = new String(receivePacketBuffer.getData(), ENCODE);

Review comment:
       Maybe you misunderstanding my point. You should do this 
   
   ```
    multicastSocket.receive(receivePacketBuffer);
   int len = multicastSocket.getLength() ;
   if(len > 0) {
      String receivedPacketString = new String(receivePacketBuffer.getData(), 0, len, ENCODE);
   }
   ```
   
   And you can avoid creating new buffers for each receive, though this is not very important because the next receive happens in seconds.




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [servicecomb-java-chassis] liubao68 commented on a change in pull request #1825: [SCB-1995]Fix incorrect message issue identifed through testing

Posted by GitBox <gi...@apache.org>.
liubao68 commented on a change in pull request #1825:
URL: https://github.com/apache/servicecomb-java-chassis/pull/1825#discussion_r437823717



##########
File path: service-registry/registry-zero-config/src/main/java/org/apache/servicecomb/zeroconfig/server/ServerUtil.java
##########
@@ -179,12 +179,12 @@ private static ServerMicroserviceInstance buildServerMicroserviceInstanceFromMap
 
   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
 
       while (true) {
+        byte[] buffer = new byte[DATA_PACKET_BUFFER_SIZE];
         DatagramPacket receivePacketBuffer = new DatagramPacket(buffer, buffer.length);
         multicastSocket.receive(receivePacketBuffer);
         String receivedPacketString = new String(receivePacketBuffer.getData(), ENCODE);

Review comment:
       Maybe you misunderstanding my point. You should do this 
   
   ```
    multicastSocket.receive(receivePacketBuffer);
   int len = receivePacketBuffer.getLength() ;
   if(len > 0) {
      String receivedPacketString = new String(receivePacketBuffer.getData(), 0, len, ENCODE);
   }
   ```
   
   And you can avoid creating new buffers for each receive, though this is not very important because the next receive happens in seconds.




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [servicecomb-java-chassis] liubao68 commented on a change in pull request #1825: [SCB-1995]Fix incorrect message issue identifed through testing

Posted by GitBox <gi...@apache.org>.
liubao68 commented on a change in pull request #1825:
URL: https://github.com/apache/servicecomb-java-chassis/pull/1825#discussion_r437823717



##########
File path: service-registry/registry-zero-config/src/main/java/org/apache/servicecomb/zeroconfig/server/ServerUtil.java
##########
@@ -179,12 +179,12 @@ private static ServerMicroserviceInstance buildServerMicroserviceInstanceFromMap
 
   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
 
       while (true) {
+        byte[] buffer = new byte[DATA_PACKET_BUFFER_SIZE];
         DatagramPacket receivePacketBuffer = new DatagramPacket(buffer, buffer.length);
         multicastSocket.receive(receivePacketBuffer);
         String receivedPacketString = new String(receivePacketBuffer.getData(), ENCODE);

Review comment:
       Maybe you misunderstanding my point. You should do this 
   
   ```
    multicastSocket.receive(receivePacketBuffer);
   int len = multicastSocket.getLength() ;
   if(len > 0) {
      String receivedPacketString = new String(receivePacketBuffer.getData(), 0, len, ENCODE);
   }
   ```




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [servicecomb-java-chassis] liubao68 merged pull request #1825: [SCB-1995]Fix incorrect message issue identifed through testing

Posted by GitBox <gi...@apache.org>.
liubao68 merged pull request #1825:
URL: https://github.com/apache/servicecomb-java-chassis/pull/1825


   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [servicecomb-java-chassis] coveralls edited a comment on pull request #1825: [SCB-1995]Fix incorrect message issue identifed through testing

Posted by GitBox <gi...@apache.org>.
coveralls edited a comment on pull request #1825:
URL: https://github.com/apache/servicecomb-java-chassis/pull/1825#issuecomment-641591330


   
   [![Coverage Status](https://coveralls.io/builds/31355511/badge)](https://coveralls.io/builds/31355511)
   
   Coverage increased (+0.4%) to 86.816% when pulling **c497ee142e3af48f7e38b051cad0e309505449ce on jungan21:master** into **1c4f7c61d70bdac7df6f8ab2adc0f020c1d5db73 on apache:master**.
   


----------------------------------------------------------------
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:
users@infra.apache.org