ijokarumawak commented on a change in pull request #3573: NIFI-6419: Fixed 
AvroWriter single record with external schema result…
URL: https://github.com/apache/nifi/pull/3573#discussion_r302867552
 
 

 ##########
 File path: 
nifi-nar-bundles/nifi-standard-services/nifi-record-serialization-services-bundle/nifi-record-serialization-services/src/main/java/org/apache/nifi/avro/WriteAvroResultWithExternalSchema.java
 ##########
 @@ -78,14 +78,19 @@ protected void onBeginRecordSet() throws IOException {
     @Override
     public Map<String, String> writeRecord(final Record record) throws 
IOException {
         // If we are not writing an active record set, then we need to ensure 
that we write the
-        // schema information.
+        // schema information at the beginning and call flush at the end.
         if (!isActiveRecordSet()) {
             flush();
             schemaAccessWriter.writeHeader(recordSchema, getOutputStream());
         }
 
         final GenericRecord rec = AvroTypeUtil.createAvroRecord(record, 
avroSchema);
         datumWriter.write(rec, encoder);
+
+        if (!isActiveRecordSet()) {
+            flush();
 
 Review comment:
   Thanks @turcsanyip! Yeah, I thought the same thing. I cannot think of any 
necessity of the `flush()` at the beginning of `writeRecord()`, but let's focus 
on fixing the current issue this time.
   
   I'm going to merge your commits. Thanks!

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to