You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by ma...@apache.org on 2022/03/01 22:53:09 UTC

[nifi] branch main updated: NIFI-9741: Make the close() method of WriteAvroResultWithExternalSchema idempotent

This is an automated email from the ASF dual-hosted git repository.

mattyb149 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi.git


The following commit(s) were added to refs/heads/main by this push:
     new a327ba4  NIFI-9741: Make the close() method of WriteAvroResultWithExternalSchema idempotent
a327ba4 is described below

commit a327ba478ad87d28342c582de0b683b672fd4525
Author: Mark Payne <ma...@hotmail.com>
AuthorDate: Tue Mar 1 11:25:03 2022 -0500

    NIFI-9741: Make the close() method of WriteAvroResultWithExternalSchema idempotent
    
    Signed-off-by: Matthew Burgess <ma...@apache.org>
    
    This closes #5818
---
 .../org/apache/nifi/avro/WriteAvroResultWithExternalSchema.java     | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/nifi-nar-bundles/nifi-standard-services/nifi-record-serialization-services-bundle/nifi-record-serialization-services/src/main/java/org/apache/nifi/avro/WriteAvroResultWithExternalSchema.java b/nifi-nar-bundles/nifi-standard-services/nifi-record-serialization-services-bundle/nifi-record-serialization-services/src/main/java/org/apache/nifi/avro/WriteAvroResultWithExternalSchema.java
index a457f96..415951f 100644
--- a/nifi-nar-bundles/nifi-standard-services/nifi-record-serialization-services-bundle/nifi-record-serialization-services/src/main/java/org/apache/nifi/avro/WriteAvroResultWithExternalSchema.java
+++ b/nifi-nar-bundles/nifi-standard-services/nifi-record-serialization-services-bundle/nifi-record-serialization-services/src/main/java/org/apache/nifi/avro/WriteAvroResultWithExternalSchema.java
@@ -43,6 +43,7 @@ public class WriteAvroResultWithExternalSchema extends AbstractRecordSetWriter {
     private final OutputStream buffered;
     private final DatumWriter<GenericRecord> datumWriter;
     private final BlockingQueue<BinaryEncoder> recycleQueue;
+    private boolean closed = false;
 
     public WriteAvroResultWithExternalSchema(final Schema avroSchema, final RecordSchema recordSchema, final SchemaAccessWriter schemaAccessWriter,
                                              final OutputStream out, final BlockingQueue<BinaryEncoder> recycleQueue, final ComponentLog logger) {
@@ -102,6 +103,11 @@ public class WriteAvroResultWithExternalSchema extends AbstractRecordSetWriter {
 
     @Override
     public void close() throws IOException {
+        if (closed) {
+            return;
+        }
+        closed = true;
+
         if (encoder != null) {
             flush();
             recycleQueue.offer(encoder);