Skip to content

Commit

Permalink
Fix NPE
Browse files Browse the repository at this point in the history
Signed-off-by: Chase Engelbrecht <[email protected]>
  • Loading branch information
engechas committed Mar 16, 2024
1 parent 48df422 commit de59881
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This is sample file 1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This is sample file 2
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This is sample file 3
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This is sample file 4
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This is sample file 5
Original file line number Diff line number Diff line change
Expand Up @@ -424,13 +424,18 @@ public void doOutput(final Collection<Record<Event>> records) {
for (final Record<Event> record : findings) {
final Event event = record.getData();
final String ruleEngineId = event.get("RULE_ENGINE_DOC_MATCH_ID", String.class);
final String docId = ruleEngineIdToDocId.get(ruleEngineId).get(0);
final String docIndexName = ruleEngineIdToDocId.get(ruleEngineId).get(1);
final List<String> replacementFields = event.getList("RULE_ENGINE_DOC_ID_REPLACEMENT_FIELDS", String.class);
final String indexName = event.get("FINDINGS_INDEX_NAME", String.class);

event.put("index", docIndexName);
replacementFields.forEach(field -> event.put(field, docId == null ? Collections.emptyList() : List.of(docId)));
final List<String> docInfo = ruleEngineIdToDocId.get(ruleEngineId);
if (docInfo != null) {
final String docId = docInfo.get(0);
final String docIndexName = docInfo.get(1);
event.put("index", docIndexName);
replacementFields.forEach(field -> event.put(field, List.of(docId)));
} else {
replacementFields.forEach(field -> event.put(field, Collections.emptyList());
}

event.delete("RULE_ENGINE_DOC_MATCH_ID");
event.delete("RULE_ENGINE_DOC_ID_REPLACEMENT_FIELDS");
Expand Down

0 comments on commit de59881

Please sign in to comment.