Skip to content

Commit

Permalink
[ISSUE apache#4596]Fix SourceWorker#convertRecordToEvent method conve…
Browse files Browse the repository at this point in the history
…rts ConnectRecord to CloudEvent throw NPE
  • Loading branch information
mxsm committed Dec 2, 2023
1 parent 5998926 commit f45438d
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -244,12 +244,13 @@ private CloudEvent convertRecordToEvent(ConnectRecord connectRecord) {
.withData(Objects.requireNonNull(JsonUtils.toJSONString(connectRecord.getData())).getBytes(StandardCharsets.UTF_8))
.withExtension("ttl", 10000);

for (String key : connectRecord.getExtensions().keySet()) {
if (CloudEventUtil.validateExtensionType(connectRecord.getExtensionObj(key))) {
cloudEventBuilder.withExtension(key, connectRecord.getExtension(key));
if (connectRecord.getExtensions() != null) {
for (String key : connectRecord.getExtensions().keySet()) {
if (CloudEventUtil.validateExtensionType(connectRecord.getExtensionObj(key))) {
cloudEventBuilder.withExtension(key, connectRecord.getExtension(key));
}
}
}

return cloudEventBuilder.build();
}

Expand Down Expand Up @@ -329,15 +330,15 @@ public boolean commitOffsets() {
log.info("{} Committing offsets for {} acknowledged messages", this, committableOffsets.numCommittableMessages());
if (committableOffsets.hasPending()) {
log.debug("{} There are currently {} pending messages spread across {} source partitions whose offsets will not be committed. "
+ "The source partition with the most pending messages is {}, with {} pending messages",
+ "The source partition with the most pending messages is {}, with {} pending messages",
this,
committableOffsets.numUncommittableMessages(),
committableOffsets.numDeques(),
committableOffsets.largestDequePartition(),
committableOffsets.largestDequeSize());
} else {
log.debug("{} There are currently no pending messages for this offset commit; "
+ "all messages dispatched to the task's producer since the last commit have been acknowledged",
+ "all messages dispatched to the task's producer since the last commit have been acknowledged",
this);
}
}
Expand Down

0 comments on commit f45438d

Please sign in to comment.