diff options
author | 2022-03-18 13:24:06 +0100 | |
---|---|---|
committer | 2022-03-18 13:24:06 +0100 | |
commit | ea23e0c6526ae0fa649ad5657ac19d27a5aa46d0 (patch) | |
tree | ad4809053eabfd5ca2b0bfc200992e9c4de1203f | |
parent | 8f9596d529df852ec97eef15c22c62b4a3acae8e (diff) |
Fix NullPointerException when k8s resource labels is null
Check if labels is not null to avoid NullPointerException. When the lebels is null empty list should be returned.
Issue-ID: SO-3908
Signed-off-by: Michal Chabiera <michal.chabiera@orange.com>
Change-Id: I5450d723f189e97aea2f81e739a4f3e3e6547c66
-rw-r--r-- | so-cnf-adapter-application/src/main/java/org/onap/so/adapters/cnf/service/aai/AaiResponseParser.java | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/so-cnf-adapter-application/src/main/java/org/onap/so/adapters/cnf/service/aai/AaiResponseParser.java b/so-cnf-adapter-application/src/main/java/org/onap/so/adapters/cnf/service/aai/AaiResponseParser.java index 0b300c4..114b776 100644 --- a/so-cnf-adapter-application/src/main/java/org/onap/so/adapters/cnf/service/aai/AaiResponseParser.java +++ b/so-cnf-adapter-application/src/main/java/org/onap/so/adapters/cnf/service/aai/AaiResponseParser.java @@ -89,13 +89,15 @@ public class AaiResponseParser { private List<String> parseLabels(Map<String, String> labels) { List<String> result = new ArrayList<>(); - labels.entrySet().stream() - .filter(i -> i.getKey().equals(INSTANCE_ID)) - .findFirst() - .ifPresent(i -> addLabelEntry(i, result)); - labels.entrySet().stream() - .filter(i -> !i.getKey().equals(INSTANCE_ID)) - .forEach(i -> addLabelEntry(i, result)); + if (labels != null) { + labels.entrySet().stream() + .filter(i -> i.getKey().equals(INSTANCE_ID)) + .findFirst() + .ifPresent(i -> addLabelEntry(i, result)); + labels.entrySet().stream() + .filter(i -> !i.getKey().equals(INSTANCE_ID)) + .forEach(i -> addLabelEntry(i, result)); + } return result; } |