mirror of
https://github.com/apache/nifi.git
synced 2025-02-07 18:48:51 +00:00
NIFI-9741: Make the close() method of WriteAvroResultWithExternalSchema idempotent
Signed-off-by: Matthew Burgess <mattyb149@apache.org> This closes #5818
This commit is contained in:
parent
d17fcf6427
commit
a327ba478a
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user