|
17 | 17 |
|
18 | 18 | package org.apache.eventmesh.client.tcp.common;
|
19 | 19 |
|
20 |
| -import io.cloudevents.CloudEvent; |
21 |
| -import io.cloudevents.SpecVersion; |
22 |
| -import io.cloudevents.core.provider.EventFormatProvider; |
23 |
| -import io.openmessaging.api.Message; |
24 | 20 | import org.apache.eventmesh.common.Constants;
|
25 | 21 | import org.apache.eventmesh.common.protocol.SubscriptionItem;
|
26 | 22 | import org.apache.eventmesh.common.protocol.SubscriptionMode;
|
27 | 23 | import org.apache.eventmesh.common.protocol.SubscriptionType;
|
| 24 | +import org.apache.eventmesh.common.protocol.tcp.Command; |
| 25 | +import org.apache.eventmesh.common.protocol.tcp.EventMeshMessage; |
| 26 | +import org.apache.eventmesh.common.protocol.tcp.Header; |
28 | 27 | import org.apache.eventmesh.common.protocol.tcp.Package;
|
29 |
| -import org.apache.eventmesh.common.protocol.tcp.*; |
30 |
| -import org.assertj.core.util.Preconditions; |
| 28 | +import org.apache.eventmesh.common.protocol.tcp.Subscription; |
| 29 | +import org.apache.eventmesh.common.protocol.tcp.UserAgent; |
| 30 | + |
31 | 31 |
|
32 | 32 | import java.util.ArrayList;
|
33 | 33 | import java.util.List;
|
34 |
| -import java.util.Objects; |
35 | 34 | import java.util.concurrent.ThreadLocalRandom;
|
36 | 35 | import java.util.stream.IntStream;
|
37 | 36 |
|
| 37 | +import org.assertj.core.util.Preconditions; |
| 38 | + |
| 39 | +import io.cloudevents.CloudEvent; |
| 40 | +import io.cloudevents.SpecVersion; |
| 41 | +import io.cloudevents.core.provider.EventFormatProvider; |
| 42 | +import io.openmessaging.api.Message; |
| 43 | + |
38 | 44 | public class MessageUtils {
|
39 | 45 | private static final int SEQ_LENGTH = 10;
|
40 | 46 |
|
@@ -89,11 +95,12 @@ public static Package buildPackage(Object message, Command command) {
|
89 | 95 | msg.setHeader(new Header(command, 0, null, generateRandomString()));
|
90 | 96 | if (message instanceof CloudEvent) {
|
91 | 97 | final CloudEvent cloudEvent = (CloudEvent) message;
|
92 |
| - Preconditions.checkNotNull(Objects.requireNonNull(cloudEvent.getDataContentType()), "DateContentType cannot be null"); |
| 98 | + Preconditions.checkNotNull(cloudEvent.getDataContentType(), "DateContentType cannot be null"); |
93 | 99 | msg.getHeader().putProperty(Constants.PROTOCOL_TYPE, EventMeshCommon.CLOUD_EVENTS_PROTOCOL_NAME);
|
94 | 100 | msg.getHeader().putProperty(Constants.PROTOCOL_VERSION, cloudEvent.getSpecVersion().toString());
|
95 | 101 | msg.getHeader().putProperty(Constants.PROTOCOL_DESC, "tcp");
|
96 |
| - final byte[] bodyByte = Objects.requireNonNull(EventFormatProvider.getInstance().resolveFormat(cloudEvent.getDataContentType())) |
| 102 | + |
| 103 | + final byte[] bodyByte = EventFormatProvider.getInstance().resolveFormat(cloudEvent.getDataContentType()) |
97 | 104 | .serialize((CloudEvent) message);
|
98 | 105 | msg.setBody(bodyByte);
|
99 | 106 | } else if (message instanceof EventMeshMessage) {
|
|
0 commit comments