Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,13 @@ public void onTrigger(final ProcessContext context, final ProcessSession session
for (final FlowFile flowFile : flowFiles) {
final String firehoseStreamName = context.getProperty(KINESIS_FIREHOSE_DELIVERY_STREAM_NAME).evaluateAttributeExpressions(flowFile).getValue();

recordHash.computeIfAbsent(firehoseStreamName, k -> new ArrayList<>());
session.read(flowFile, in -> recordHash.get(firehoseStreamName).add(Record.builder().data(SdkBytes.fromInputStream(in)).build()));
// Use a single computeIfAbsent().add() call so the list lookup is atomic.
// The previous two-step pattern (computeIfAbsent then a separate get()) could
// throw NullPointerException when firehoseStreamName evaluates to null via
// expression language, because get(null) returned null after the absent-key
// entry was never actually inserted. (NIFI-14472)
session.read(flowFile, in -> recordHash.computeIfAbsent(firehoseStreamName, k -> new ArrayList<>())
.add(Record.builder().data(SdkBytes.fromInputStream(in)).build()));

final List<FlowFile> flowFilesForStream = hashFlowFiles.computeIfAbsent(firehoseStreamName, k -> new ArrayList<>());
flowFilesForStream.add(flowFile);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import org.apache.nifi.parameter.ParameterLookup;
import org.apache.nifi.util.MockProcessContext;
import org.apache.nifi.util.MockValidationContext;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
Expand Down Expand Up @@ -107,6 +108,11 @@ void setProvider() {
provider = new MockKubernetesConfigMapStateProvider();
}

@AfterEach
void shutdownProvider() {
provider.shutdown();
}

@Test
void testGetSupportedScopes() {
final Scope[] supportedScopes = provider.getSupportedScopes();
Expand Down
Loading