You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@eventmesh.apache.org by "silentchildh (via GitHub)" <gi...@apache.org> on 2023/07/28 01:23:01 UTC

Re: [PR] [ISSUE #4268] Used switch to replace the if-else [CloudEventsProtocolAdaptor] (eventmesh)

silentchildh commented on code in PR #4298:
URL: https://github.com/apache/eventmesh/pull/4298#discussion_r1276985757


##########
eventmesh-protocol-plugin/eventmesh-protocol-cloudevents/src/main/java/org/apache/eventmesh/protocol/cloudevents/CloudEventsProtocolAdaptor.java:
##########
@@ -89,16 +87,16 @@ private CloudEvent deserializeHttpProtocol(String requestCode,
         org.apache.eventmesh.common.protocol.http.header.Header header,
         Body body) throws ProtocolHandleException {
 
-        if (String.valueOf(RequestCode.MSG_BATCH_SEND.getRequestCode()).equals(requestCode)) {
-            return SendMessageBatchProtocolResolver.buildEvent(header, body);
-        } else if (String.valueOf(RequestCode.MSG_BATCH_SEND_V2.getRequestCode()).equals(requestCode)) {
-            return SendMessageBatchV2ProtocolResolver.buildEvent(header, body);
-        } else if (String.valueOf(RequestCode.MSG_SEND_SYNC.getRequestCode()).equals(requestCode)) {
-            return SendMessageRequestProtocolResolver.buildEvent(header, body);
-        } else if (String.valueOf(RequestCode.MSG_SEND_ASYNC.getRequestCode()).equals(requestCode)) {
-            return SendMessageRequestProtocolResolver.buildEvent(header, body);
-        } else {
-            throw new ProtocolHandleException(String.format("unsupported requestCode: %s", requestCode));
+        switch (RequestCode.valueOf(requestCode)) {

Review Comment:
   `valueOf` method is to transfer an Enum constant specified name to return an  Enum constant.So It can not transfer `requestCode` as specified name to get any Enum constant.
   ![image](https://github.com/apache/eventmesh/assets/122422744/ba9f26f7-74fa-43f6-93be-8553809ca3e3)
   
   So as the same as #4270.It causes client to fail to connect to the runtime server.
   ![image](https://github.com/apache/eventmesh/assets/122422744/a1b43423-c607-4dfb-a9e4-b0b712e66251)
   
   



-- 
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: issues-unsubscribe@eventmesh.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org