You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by GitBox <gi...@apache.org> on 2022/12/21 01:34:34 UTC

[GitHub] [rocketmq] mxsm commented on issue #5742: RemotingCommand static code is wrong

mxsm commented on issue #5742:
URL: https://github.com/apache/rocketmq/issues/5742#issuecomment-1360649821

   Hi @xiaorongZheng  SerializeType#valueof paramter is string that this method is enum method, you can custom a enum has the valueof (String xxx) method. So this code is correct. 
   
   ```java
       public static SerializeType valueOf(byte code) {
           for (SerializeType serializeType : SerializeType.values()) {
               if (serializeType.getCode() == code) {
                   return serializeType;
               }
           }
           return null;
       }
   ```
   The above code was used in the following place.
   ```java
   //RemotingCommand#getProtocolType
       public static SerializeType getProtocolType(int source) {
           return SerializeType.valueOf((byte) ((source >> 24) & 0xFF));
       }
   ```
   
   
   


-- 
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: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org