Skip to content

Commit aac28a7

Browse files
some refactoring
Refactoring to avoid some exceptions
1 parent d456239 commit aac28a7

File tree

5 files changed

+230
-236
lines changed

5 files changed

+230
-236
lines changed

src/main/java/com/ericsson/ei/handlers/HistoryExtractionHandler.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import com.ericsson.ei.rules.RulesObject;
2121
import com.fasterxml.jackson.databind.JsonNode;
2222
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
23+
import com.fasterxml.jackson.databind.node.NullNode;
2324
import com.github.wnameless.json.flattener.JsonFlattener;
2425

2526
import org.slf4j.Logger;
@@ -58,11 +59,13 @@ public class HistoryExtractionHandler {
5859
public String runHistoryExtraction(String aggregatedObjectId, RulesObject rules, String event,
5960
String pathInAggregatedObject) {
6061
JsonNode objectToMerge = extractContent(rules, event);
61-
if (objectToMerge == null) {
62+
if (objectToMerge instanceof NullNode) {
6263
return pathInAggregatedObject;
6364
}
6465

6566
JsonNode ruleJson = getHistoryPathRule(rules, event);
67+
if (ruleJson instanceof NullNode)
68+
return pathInAggregatedObject;
6669
String ruleString = ruleJson.toString();
6770

6871
// if we need to add append to an array then array_path will not be
@@ -155,7 +158,7 @@ private JsonNode getHistoryPathRule(RulesObject rulesObject, String event) {
155158
if (rule != null)
156159
return jmesPathInterface.runRuleOnEvent(rule, event);
157160

158-
return JsonNodeFactory.instance.objectNode();
161+
return JsonNodeFactory.instance.nullNode();
159162
}
160163

161164
}

0 commit comments

Comments
 (0)