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


##########
eventmesh-sdks/eventmesh-sdk-java/src/main/java/org/apache/eventmesh/client/grpc/util/EventMeshCloudEventBuilder.java:
##########
@@ -190,56 +187,25 @@ private static CloudEvent 
switchEventMeshMessage2EventMeshCloudEvent(EventMeshMe
 
     private static CloudEvent 
switchCloudEvent2EventMeshCloudEvent(io.cloudevents.CloudEvent message, 
EventMeshGrpcClientConfig clientConfig,
         EventMeshProtocolType protocolType) {
-        final io.cloudevents.CloudEvent cloudEvent = message;
-        CloudEventBuilder cloudEventBuilder = 
CloudEventBuilder.from(cloudEvent);
-        if (null == cloudEvent.getExtension(ProtocolKey.ENV)) {
-            cloudEventBuilder.withExtension(ProtocolKey.ENV, 
clientConfig.getEnv());
-        }
-        if (null == cloudEvent.getExtension(ProtocolKey.IDC)) {
-            cloudEventBuilder.withExtension(ProtocolKey.IDC, 
clientConfig.getEnv());
-        }
-        if (null == cloudEvent.getExtension(ProtocolKey.IP)) {
-            cloudEventBuilder.withExtension(ProtocolKey.IP, 
Objects.requireNonNull(IPUtils.getLocalAddress()));
-        }
-        if (null == cloudEvent.getExtension(ProtocolKey.PID)) {
-            cloudEventBuilder.withExtension(ProtocolKey.PID, 
Long.toString(ThreadUtils.getPID()));
-        }
-        if (null == cloudEvent.getExtension(ProtocolKey.SYS)) {
-            cloudEventBuilder.withExtension(ProtocolKey.SYS, 
clientConfig.getSys());
-        }
 
-        if (null == cloudEvent.getExtension(ProtocolKey.LANGUAGE)) {
-            cloudEventBuilder.withExtension(ProtocolKey.LANGUAGE, 
Constants.LANGUAGE_JAVA);
-        }
+        CloudEventBuilder cloudEventBuilder = CloudEventBuilder.from(message);
+
+        builderCloudEvent(message, cloudEventBuilder, ProtocolKey.ENV, 
clientConfig.getEnv());
+        builderCloudEvent(message, cloudEventBuilder, ProtocolKey.IDC, 
clientConfig.getIdc());
+        builderCloudEvent(message, cloudEventBuilder, ProtocolKey.IP, 
Objects.requireNonNull(IPUtils.getLocalAddress()));

Review Comment:
   > How about changing the method name to `buildCloudEvent`?
   
   Yes, it does. `buildCloudEvent` seems to fit this behavior better.



-- 
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: [email protected]

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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to