Our Community is getting an upgrade! To get everything ready for the relaunch, we’ll be placing the site in read-only mode starting September 21st.
We really appreciate your understanding while we get things set up behind the scenes. Catch up on all the exciting details about the move here.
Need help or have questions? Drop us a line at [email protected]

Support Questions

Find answers, ask questions, and share your expertise
Announcements
Share your experience with Cloudera on G2 and get a $25 Amazon Gift card.
Hi, I'm CLEO! Something exciting is coming to the Community. Stay Tuned!

org.apache.nifi.util.TestRunners giving error in Nifi unit test - As of version 1.14.0, ProcessSession.commit() should be avoided when possible.

avatar
Master Collaborator

Hello Experts,

 

I am using org.apache.nifi.util.TestRunners in Nifi custom processor unit test cases, and code something like below..

 

Spoiler
testRunner = TestRunners.newTestRunner(O9QueueRouting.class);
.
.
.
.

MockFlowFile ff = this.testRunner.enqueue(new ByteArrayInputStream(ffContents.getBytes(StandardCharsets.UTF_8)));
Map<String, String> attrs = new HashMap<String, String>();
attrs.put("routingheader", "headervalue");
attrs.put("kafka.topic", "topic1");
ff.putAttributes(attrs);
testRunner.run();


It was working earlier now started giving error like below -

[ERROR] O9QueueRoutingTest.test:73 java.lang.RuntimeException: As of version 1.14.0, ProcessSession.commit() should be avoided when possible.
See JavaDocs for explanations. Instead, use commitAsync(), commitAsync(Runnable), or commitAsync(Runnable, Consumer<Throwable>). However, if this is not possible,
ProcessSession.commit() may still be used, but this must be explicitly enabled by calling TestRunner.

 

Any idea how this can be resolved ?
How to explicitly enable by calling TestRunner ?

Thanks
Mahendra

1 ACCEPTED SOLUTION

avatar
Master Collaborator
testRunner.setAllowSynchronousSessionCommits(true);

Helped me to get rid of this error 

View solution in original post

1 REPLY 1

avatar
Master Collaborator
testRunner.setAllowSynchronousSessionCommits(true);

Helped me to get rid of this error