Commit 67c2d4c
committed
NIFI-14472: Fixed NullPointerException in PutKinesisFirehose when stream name evaluates to null
The onTrigger() method used a two-step pattern to populate the recordHash map:
1. recordHash.computeIfAbsent(firehoseStreamName, k -> new ArrayList<>())
2. recordHash.get(firehoseStreamName).add(record) // ← NPE here
When the KINESIS_FIREHOSE_DELIVERY_STREAM_NAME expression evaluates to null
(e.g., the referenced FlowFile attribute is absent), computeIfAbsent(null, ...)
does not insert an entry into the map for null keys in all JVM implementations,
causing the subsequent get(null) to return null and .add() to throw:
NullPointerException: Cannot invoke List.add() because Map.get() returns null
- Collapsed the two-step lookup into a single atomic computeIfAbsent().add()
call, eliminating the null-return window between the two statements
- The fix applies to the recordHash population step; hashFlowFiles already
used computeIfAbsent correctly in a single step on the following line
Co-authored-by: Rakesh Kumar Singh <rsky.rakesh@gmail.com>1 parent 749b702 commit 67c2d4c
1 file changed
Lines changed: 7 additions & 2 deletions
File tree
- nifi-extension-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/kinesis/firehose
Lines changed: 7 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
134 | 134 | | |
135 | 135 | | |
136 | 136 | | |
137 | | - | |
138 | | - | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
139 | 144 | | |
140 | 145 | | |
141 | 146 | | |
| |||
0 commit comments