From 69712c820f5ed9345f0f788f8dea4ae16f5f5f00 Mon Sep 17 00:00:00 2001 From: Jan Malkiewicz Date: Fri, 8 Jan 2021 14:28:15 +0100 Subject: Fix NPE Fix NPE during the onboarding of a helm package. NPE was thrown in HeatTreeManager.handleOrphans(): * tree.getHeat()::contains Issue-ID: SDC-3185 Signed-off-by: Jan Malkiewicz Change-Id: I9e0461cfe18705b6fb53ae318e473bd4e2651305 --- .../datatypes/structure/HeatStructureTree.java | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp') diff --git a/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/structure/HeatStructureTree.java b/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/structure/HeatStructureTree.java index a65db6f2ea..93eb7c649d 100644 --- a/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/structure/HeatStructureTree.java +++ b/openecomp-be/lib/openecomp-heat-lib/src/main/java/org/openecomp/sdc/heat/datatypes/structure/HeatStructureTree.java @@ -4,6 +4,8 @@ * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * ================================================================================ + * Modifications Copyright (C) 2021 Nokia + * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -24,7 +26,6 @@ import java.util.ArrayList; import java.util.List; import java.util.Set; import java.util.TreeSet; - import lombok.AccessLevel; import lombok.Data; import lombok.Getter; @@ -53,9 +54,11 @@ public class HeatStructureTree implements Comparable { private Set helm; public HeatStructureTree() { + heat = new TreeSet<>(); } public HeatStructureTree(String fileName, boolean isBase) { + this(); this.isBase = isBase; this.fileName = fileName; } @@ -76,7 +79,7 @@ public class HeatStructureTree implements Comparable { * @return the heat structure tree by name */ public static HeatStructureTree getHeatStructureTreeByName(Set filesSet, - String filename) { + String filename) { for (HeatStructureTree heatStructureTree : filesSet) { if (heatStructureTree.getFileName().equals(filename)) { return heatStructureTree; @@ -166,7 +169,7 @@ public class HeatStructureTree implements Comparable { this.other.add(other); } - public void addToHelmList(HeatStructureTree helm){ + public void addToHelmList(HeatStructureTree helm) { if (this.helm == null) { this.helm = new TreeSet<>(); } @@ -198,7 +201,7 @@ public class HeatStructureTree implements Comparable { */ public void removeFromVolumeOrNetwork(String fileNameToRemove, FileData.Type type) { Set volumeOrNetworkSet = - type.equals(FileData.Type.HEAT_VOL) ? this.volume : this.network; + type.equals(FileData.Type.HEAT_VOL) ? this.volume : this.network; HeatStructureTree toRemove = getHeatStructureTreeByName(volumeOrNetworkSet, fileNameToRemove); volumeOrNetworkSet.remove(toRemove); @@ -215,7 +218,6 @@ public class HeatStructureTree implements Comparable { result1 = 31 * result1 + (nested != null ? nested.hashCode() : 0); result1 = 31 * result1 + (errors != null ? errors.hashCode() : 0); - return result1; } @@ -231,7 +233,7 @@ public class HeatStructureTree implements Comparable { HeatStructureTree heatStructureTree = (HeatStructureTree) other; if (fileName != null ? !fileName.equals(heatStructureTree.fileName) - : heatStructureTree.fileName != null) { + : heatStructureTree.fileName != null) { return false; } if (env != null ? !env.equals(heatStructureTree.env) : heatStructureTree.env != null) { @@ -241,19 +243,19 @@ public class HeatStructureTree implements Comparable { return false; } if (volume != null ? !volume.equals(heatStructureTree.volume) - : heatStructureTree.volume != null) { + : heatStructureTree.volume != null) { return false; } if (network != null ? !network.equals(heatStructureTree.network) - : heatStructureTree.network != null) { + : heatStructureTree.network != null) { return false; } if (artifacts != null ? !artifacts.equals(heatStructureTree.artifacts) - : heatStructureTree.artifacts != null) { + : heatStructureTree.artifacts != null) { return false; } if (nested != null ? !nested.equals(heatStructureTree.nested) - : heatStructureTree.nested != null) { + : heatStructureTree.nested != null) { return false; } -- cgit 1.2.3-korg