Skip to content
Merged
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 @@ -72,7 +72,7 @@ public void parse(InputStream inputStream, Instant timeReceived, Consumer<Record
}

if (jsonParser.getCurrentToken() == JsonToken.START_ARRAY) {
if (keyName != null && !nodeName.equals(keyName)) {
if (keyName != null && !keyName.equals(nodeName)) {
continue;
}
parseRecordsArray(jsonParser, timeReceived, eventConsumer, includeKeysMap, includeMetadataKeysMap);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,20 @@ void test_basicJsonDecoder_withInputConfig() throws IOException {
assertThat(receivedTime, equalTo(now));
}

@Test
void test_JsonDecoder_withKeyName_when_parsing_json_array_should_skip() throws IOException {
final Instant now = Instant.now();
String inputString = "[]";
List<Record<Event>> records = new ArrayList<>();
jsonDecoder = new JsonDecoder(key_name, null, null, maxEventLength);
jsonDecoder.parse(new ByteArrayInputStream(inputString.getBytes()), now, (record) -> {
records.add(record);
receivedTime = record.getData().getEventHandle().getInternalOriginationTime();
});

assertTrue(records.isEmpty());
}

@Test
void test_basicJsonDecoder_withInputConfig_withoutEvents_empty_metadata_keys() throws IOException {
final Instant now = Instant.now();
Expand Down
Loading