Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ISSUE #3095] Handling possible NullPointerException[MessageUtils] #4870

Merged
merged 1 commit into from
May 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.ThreadLocalRandom;
import java.util.stream.IntStream;

Expand Down Expand Up @@ -83,12 +84,12 @@ public static Package buildPackage(Object message, Command command) {
final Package msg = getPackage(command);
if (message instanceof CloudEvent) {
final CloudEvent cloudEvent = (CloudEvent) message;
Preconditions.checkNotNull(cloudEvent.getDataContentType(), "DateContentType cannot be null");
Preconditions.checkNotNull(Objects.requireNonNull(cloudEvent.getDataContentType()), "DateContentType cannot be null");
msg.getHeader().putProperty(Constants.PROTOCOL_TYPE, CLOUD_EVENTS_PROTOCOL_NAME);
msg.getHeader().putProperty(Constants.PROTOCOL_VERSION, cloudEvent.getSpecVersion().toString());
msg.getHeader().putProperty(Constants.PROTOCOL_DESC, "tcp");

final byte[] bodyByte = EventFormatProvider.getInstance().resolveFormat(cloudEvent.getDataContentType())
final byte[] bodyByte = Objects.requireNonNull(EventFormatProvider.getInstance().resolveFormat(cloudEvent.getDataContentType()))
.serialize((CloudEvent) message);
msg.setBody(bodyByte);
} else if (message instanceof EventMeshMessage) {
Expand Down
Loading