Skip to content

NIFI-15709 Close OutputStream when schema retrieval fails in RecordWriter#10997

Merged
pvillard31 merged 1 commit intoapache:mainfrom
Chaffelson:NIFI-15709
Mar 12, 2026
Merged

NIFI-15709 Close OutputStream when schema retrieval fails in RecordWriter#10997
pvillard31 merged 1 commit intoapache:mainfrom
Chaffelson:NIFI-15709

Conversation

@Chaffelson
Copy link
Contributor

Summary

Fixes a bug in RecordWriter where an unclosed OutputStream causes IllegalStateException when processing JMS messages with Record Reader/Writer.

Problem

When writerFactory.getSchema() throws an exception (line 134), the OutputStream opened by session.write(flowFile) (line 130) is not closed before the continue statement. This leaves the FlowFile in an invalid state. When recordCount == 0, session.remove(flowFile) fails with:

java.lang.IllegalStateException: StandardFlowFileRecord[...] already in use for an active callback or an OutputStream created by ProcessSession.write(FlowFile) has not been closed

Fix

Close rawOut in the catch block before continuing to the next message.

Testing

  • Existing unit tests pass
  • Manual verification with ConsumeJMS + JsonTreeReader + JsonRecordSetWriter + "Use Wrapper" output strategy

JIRA

https://issues.apache.org/jira/browse/NIFI-15709

…iter

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.
@pvillard31 pvillard31 merged commit 9ffc257 into apache:main Mar 12, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants