Fix to avoid ConcurrentModificationException in policy-models 49/102149/3
authora.sreekumar <ajith.sreekumar@est.tech>
Fri, 21 Feb 2020 14:06:57 +0000 (14:06 +0000)
committera.sreekumar <ajith.sreekumar@est.tech>
Mon, 24 Feb 2020 10:31:01 +0000 (10:31 +0000)
Change-Id: If911bdd4116b722e13e00199d05b1794de4e79c2
Issue-ID: POLICY-1402
Signed-off-by: a.sreekumar <ajith.sreekumar@est.tech>
models-tosca/src/main/java/org/onap/policy/models/tosca/utils/ToscaUtils.java

index 88591bd..3f2ebe7 100644 (file)
@@ -234,16 +234,16 @@ public final class ToscaUtils {
         @SuppressWarnings("unchecked")
         Set<JpaToscaEntityType<ToscaEntity>> ancestorEntitySet = (Set<JpaToscaEntityType<ToscaEntity>>) entityTypes
                 .getAll(parentEntityTypeKey.getName(), parentEntityTypeKey.getVersion());
-
+        Set<JpaToscaEntityType<ToscaEntity>> ancestorEntitySetToReturn = new HashSet<>(ancestorEntitySet);
         if (ancestorEntitySet.isEmpty()) {
             result.addValidationMessage(new PfValidationMessage(entityType.getKey(), ToscaUtils.class,
                     ValidationResult.INVALID, "parent " + parentEntityTypeKey.getId() + " of entity not found"));
         } else {
             for (JpaToscaEntityType<?> filteredEntityType : ancestorEntitySet) {
-                ancestorEntitySet.addAll(getEntityTypeAncestors(entityTypes, filteredEntityType, result));
+                ancestorEntitySetToReturn.addAll(getEntityTypeAncestors(entityTypes, filteredEntityType, result));
             }
         }
-        return ancestorEntitySet;
+        return ancestorEntitySetToReturn;
     }
 
     /**