This is an automated email from the ASF dual-hosted git repository.
mxsm pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/eventmesh.git
The following commit(s) were added to refs/heads/master by this push:
new fe13a8571 [ISSUE #4267] Optimized
[GrpcEventMeshCloudEventProtocolResolver] (#4279)
fe13a8571 is described below
commit fe13a85713f6b7cf39ccce62ac8aef40380941b6
Author: Sam V Jose <[email protected]>
AuthorDate: Tue Jul 25 20:35:27 2023 +0530
[ISSUE #4267] Optimized [GrpcEventMeshCloudEventProtocolResolver] (#4279)
* [ISSUE #4269] Used switch to replace the if-else.
[MeshMessageProtocolAdaptor]
* [ISSUE #4269] Used switch to replace the if-else.
[MeshMessageProtocolAdaptor]
* [ISSUE #4269] Used switch to replace the if-else.
[MeshMessageProtocolAdaptor]
* [ISSUE #4269] Used switch to replace the if-else.
[MeshMessageProtocolAdaptor]
* [ISSUE #4267] Optimized [GrpcEventMeshCloudEventProtocolResolver]
* [ISSUE #4267] Optimized [GrpcEventMeshCloudEventProtocolResolver]
---
.../resolver/grpc/GrpcEventMeshCloudEventProtocolResolver.java | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git
a/eventmesh-protocol-plugin/eventmesh-protocol-cloudevents/src/main/java/org/apache/eventmesh/protocol/cloudevents/resolver/grpc/GrpcEventMeshCloudEventProtocolResolver.java
b/eventmesh-protocol-plugin/eventmesh-protocol-cloudevents/src/main/java/org/apache/eventmesh/protocol/cloudevents/resolver/grpc/GrpcEventMeshCloudEventProtocolResolver.java
index 99a6b92bf..a00d1852a 100644
---
a/eventmesh-protocol-plugin/eventmesh-protocol-cloudevents/src/main/java/org/apache/eventmesh/protocol/cloudevents/resolver/grpc/GrpcEventMeshCloudEventProtocolResolver.java
+++
b/eventmesh-protocol-plugin/eventmesh-protocol-cloudevents/src/main/java/org/apache/eventmesh/protocol/cloudevents/resolver/grpc/GrpcEventMeshCloudEventProtocolResolver.java
@@ -17,13 +17,13 @@
package org.apache.eventmesh.protocol.cloudevents.resolver.grpc;
-
import org.apache.eventmesh.common.protocol.grpc.cloudevents.CloudEvent;
import org.apache.eventmesh.common.protocol.grpc.cloudevents.CloudEventBatch;
import
org.apache.eventmesh.common.protocol.grpc.common.EventMeshCloudEventWrapper;
import java.util.ArrayList;
import java.util.List;
+import java.util.Objects;
import java.util.stream.Collectors;
import io.cloudevents.core.format.EventFormat;
@@ -40,15 +40,14 @@ public class GrpcEventMeshCloudEventProtocolResolver {
private static final EventFormat eventFormat =
EventFormatProvider.getInstance().resolveFormat(ProtobufFormat.PROTO_CONTENT_TYPE);
public static io.cloudevents.CloudEvent buildEvent(CloudEvent cloudEvent) {
- io.cloudevents.CloudEvent event =
eventFormat.deserialize(cloudEvent.toByteArray());
- return event;
+ return
Objects.requireNonNull(eventFormat).deserialize(cloudEvent.toByteArray());
}
public static List<io.cloudevents.CloudEvent>
buildBatchEvents(CloudEventBatch cloudEventBatch) {
if (cloudEventBatch == null || cloudEventBatch.getEventsCount() < 1) {
return new ArrayList<>(0);
}
- return cloudEventBatch.getEventsList().stream().map(cloudEvent ->
eventFormat.deserialize(cloudEvent.toByteArray()))
+ return cloudEventBatch.getEventsList().stream().map(cloudEvent ->
Objects.requireNonNull(eventFormat).deserialize(cloudEvent.toByteArray()))
.collect(Collectors.toList());
}
@@ -57,7 +56,7 @@ public class GrpcEventMeshCloudEventProtocolResolver {
return new EventMeshCloudEventWrapper(null);
}
try {
- return new
EventMeshCloudEventWrapper(CloudEvent.parseFrom(eventFormat.serialize(cloudEvent)));
+ return new
EventMeshCloudEventWrapper(CloudEvent.parseFrom(Objects.requireNonNull(eventFormat).serialize(cloudEvent)));
} catch (InvalidProtocolBufferException e) {
log.error("Build Event Mesh CloudEvent from
io.cloudevents.CloudEvent error", e);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]