Skip to content

Commit

Permalink
Merge pull request #123 from embano1/issue-122
Browse files Browse the repository at this point in the history
fix: remove putIfAbsent calls
  • Loading branch information
embano1 authored Sep 7, 2023
2 parents b8c261a + b511b65 commit d46309d
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,22 +73,22 @@ private String createJsonPayload(SinkRecord record) throws IOException {
root.put("offset", record.kafkaOffset());
root.put("timestamp", record.timestamp());
root.put("timestampType", record.timestampType().toString());
root.putIfAbsent("headers", createHeaderArray(record));
root.set("headers", createHeaderArray(record));

if (record.key() == null) {
root.putIfAbsent("key", null);
root.set("key", null);
} else {
root.putIfAbsent(
root.set(
"key",
createJSONFromByteArray(
jsonConverter.fromConnectData(record.topic(), record.keySchema(), record.key())));
}

// tombstone handling
if (record.value() == null) {
root.putIfAbsent("value", null);
root.set("value", null);
} else {
root.putIfAbsent(
root.set(
"value",
createJSONFromByteArray(
jsonConverter.fromConnectData(record.topic(), record.valueSchema(), record.value())));
Expand All @@ -109,7 +109,7 @@ private ArrayNode createHeaderArray(SinkRecord record) throws IOException {

for (Header header : record.headers()) {
var headerItem = objectMapper.createObjectNode();
headerItem.putIfAbsent(
headerItem.set(
header.key(),
createJSONFromByteArray(
jsonConverter.fromConnectHeader(
Expand Down

0 comments on commit d46309d

Please sign in to comment.