Skip to content

Commit 9ffc257

Browse files
authored
NIFI-15709 Close OutputStream when schema retrieval fails in RecordWriter (apache#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.
1 parent 4358374 commit 9ffc257

File tree

1 file changed

+5
-0
lines changed
  • nifi-extension-bundles/nifi-jms-bundle/nifi-jms-processors/src/main/java/org/apache/nifi/jms/processors/ioconcept/writer/record

1 file changed

+5
-0
lines changed

nifi-extension-bundles/nifi-jms-bundle/nifi-jms-processors/src/main/java/org/apache/nifi/jms/processors/ioconcept/writer/record/RecordWriter.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,11 @@ record = RecordUtils.wrap(record, "value", additionalAttributes, "_");
136136
logger.error("Failed to obtain Schema for FlowFile, sending to the parse failure relationship", e);
137137
failedMessages.add(message);
138138
flowFileWriterCallback.onParseFailure(flowFile, message, e);
139+
try {
140+
rawOut.close();
141+
} catch (final IOException ioe) {
142+
logger.warn("Failed to close output stream", ioe);
143+
}
139144
continue;
140145
}
141146

0 commit comments

Comments
 (0)