ijokarumawak commented on a change in pull request #3607: NIFI-6490 MergeRecord
supports Variable Registry for MIN_RECORDS and MAX_RECORDS
URL: https://github.com/apache/nifi/pull/3607#discussion_r308097189
##########
File path:
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/MergeRecord.java
##########
@@ -268,8 +270,8 @@ public final void resetState() {
protected Collection<ValidationResult> customValidate(final
ValidationContext validationContext) {
final List<ValidationResult> results = new ArrayList<>();
- final Integer minRecords =
validationContext.getProperty(MIN_RECORDS).asInteger();
- final Integer maxRecords =
validationContext.getProperty(MAX_RECORDS).asInteger();
+ final Integer minRecords =
validationContext.getProperty(MIN_RECORDS).evaluateAttributeExpressions().asInteger();
+ final Integer maxRecords =
validationContext.getProperty(MAX_RECORDS).evaluateAttributeExpressions().asInteger();
Review comment:
If these values are set with literal values,
StandardValidators.POSITIVE_INTEGER_VARIDATOR guarantees that they are positive
(> 0). But if it's set by EL, negative values or zero can be set and validation
passes. Eventually a NullPointerException is thrown when MergeRecord runs. I'd
suggest adding a validation confirming min/max_records are grater than zero
here, too.
```
2019-07-29 16:45:47,117 ERROR [Timer-Driven Process Thread-6]
o.a.nifi.processors.standard.MergeRecord MergeRecord[id=3c
a2eeaf-016c-1000-f20c-e1e7e984d1ad] Failed to create merged FlowFile from 2
input FlowFiles; routing originals to failur
e: java.lang.NullPointerException
java.lang.NullPointerException: null
at
org.apache.nifi.processors.standard.merge.RecordBin.offer(RecordBin.java:154)
at
org.apache.nifi.processors.standard.merge.RecordBinManager.add(RecordBinManager.java:152)
at
org.apache.nifi.processors.standard.MergeRecord.binFlowFile(MergeRecord.java:374)
at
org.apache.nifi.processors.standard.MergeRecord.onTrigger(MergeRecord.java:330)
at
org.apache.nifi.controller.StandardProcessorNode.onTrigger(StandardProcessorNode.java:1161)
at
org.apache.nifi.controller.tasks.ConnectableTask.invoke(ConnectableTask.java:213)
at
org.apache.nifi.controller.scheduling.TimerDrivenSchedulingAgent$1.run(TimerDrivenSchedulingAgent.java:117)
at org.apache.nifi.engine.FlowEngine$2.run(FlowEngine.java:110)
at
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services