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

pvillard 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 9ffc2575a95 NIFI-15709 Close OutputStream when schema retrieval fails 
in RecordWriter (#10997)
9ffc2575a95 is described below

commit 9ffc2575a95616915fe012bc4a11decea3ba11b2
Author: Dan Chaffelson <[email protected]>
AuthorDate: Thu Mar 12 12:14:02 2026 +0000

    NIFI-15709 Close OutputStream when schema retrieval fails in RecordWriter 
(#10997)
    
    When writerFactory.getSchema() throws an exception, the OutputStream
    opened by session.write(flowFile) was not being closed before the
    continue statement. This left the FlowFile in an invalid state,
    causing IllegalStateException when session.remove() was later called.
    
    This fix ensures the OutputStream is properly closed in the error
    handling path before continuing to the next message.
---
 .../nifi/jms/processors/ioconcept/writer/record/RecordWriter.java    | 5 +++++
 1 file changed, 5 insertions(+)

diff --git 
a/nifi-extension-bundles/nifi-jms-bundle/nifi-jms-processors/src/main/java/org/apache/nifi/jms/processors/ioconcept/writer/record/RecordWriter.java
 
b/nifi-extension-bundles/nifi-jms-bundle/nifi-jms-processors/src/main/java/org/apache/nifi/jms/processors/ioconcept/writer/record/RecordWriter.java
index 2187fc5715e..b4359ca9938 100644
--- 
a/nifi-extension-bundles/nifi-jms-bundle/nifi-jms-processors/src/main/java/org/apache/nifi/jms/processors/ioconcept/writer/record/RecordWriter.java
+++ 
b/nifi-extension-bundles/nifi-jms-bundle/nifi-jms-processors/src/main/java/org/apache/nifi/jms/processors/ioconcept/writer/record/RecordWriter.java
@@ -136,6 +136,11 @@ public class RecordWriter<T> implements FlowFileWriter<T> {
                                     logger.error("Failed to obtain Schema for 
FlowFile, sending to the parse failure relationship", e);
                                     failedMessages.add(message);
                                     
flowFileWriterCallback.onParseFailure(flowFile, message, e);
+                                    try {
+                                        rawOut.close();
+                                    } catch (final IOException ioe) {
+                                        logger.warn("Failed to close output 
stream", ioe);
+                                    }
                                     continue;
                                 }
 

Reply via email to