rzepinskip commented on code in PR #11899:
URL: https://github.com/apache/nifi/pull/11899#discussion_r4523621188


##########
nifi-extension-bundles/nifi-kafka-bundle/nifi-kafka-processors/src/main/java/org/apache/nifi/kafka/processors/consumer/bundle/ByteRecordBundler.java:
##########
@@ -65,8 +65,11 @@ private ByteRecord toByteRecord(final BundleKey key, final 
BundleValue value) {
         final TopicPartitionSummary topicPartition = key.getTopicPartition();
         key.headers.add(new 
RecordHeader(KafkaFlowFileAttribute.KAFKA_MAX_OFFSET, 
Long.toString(value.getLastOffset()).getBytes(StandardCharsets.UTF_8)));
         key.headers.add(new RecordHeader(KafkaFlowFileAttribute.KAFKA_COUNT, 
Long.toString(value.getCount()).getBytes(StandardCharsets.UTF_8)));
+        final byte[] data = value.getData();
+        // Demarcator emits one FlowFile per bundle, so an empty bundle is 
still reported as a tombstone.
+        final boolean tombstone = data.length == 0;
         return new ByteRecord(topicPartition.getTopic(), 
topicPartition.getPartition(),
-                value.getFirstOffset(), key.getTimestamp(), key.getHeaders(), 
key.getMessageKey(), value.getData(), value.getCount(), false);
+                value.getFirstOffset(), key.getTimestamp(), key.getHeaders(), 
key.getMessageKey(), data, value.getCount(), tombstone);

Review Comment:
   Because FLOW_FILE and DEMARCATOR use 
[FlowFileStreamKafkaMessageConverter.java‎](https://github.com/apache/nifi/pull/11899/changes#diff-db771f11851dc797c52ebb887ddf5691c3e68052efb12cfb4373aff5a0a61e2f)
 these changes are required to preserve existing behavior for DEMARCATOR:
   Records in one bundle | FlowFile content
   -- | --
   hello, tombstone, world | hello\|\|world
   hello, tombstone | hello\|
   tombstone, hello, world | hello\|world
   tombstone only (or several tombstones only) | empty + tombstone attribute
   empty | empty + tombstone attribute
   
   Added tests as well.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to