diff --git a/common/onap-common-configuration-management/onap-configuration-management-core/src/main/java/org/onap/config/impl/ConfigurationImpl.java b/common/onap-common-configuration-management/onap-configuration-management-core/src/main/java/org/onap/config/impl/ConfigurationImpl.java
index 0a5a141..5d49fa9 100644
--- a/common/onap-common-configuration-management/onap-configuration-management-core/src/main/java/org/onap/config/impl/ConfigurationImpl.java
+++ b/common/onap-common-configuration-management/onap-configuration-management-core/src/main/java/org/onap/config/impl/ConfigurationImpl.java
@@ -435,17 +435,18 @@
             field.setAccessible(true);
             Config fieldConfAnnotation = field.getAnnotation(Config.class);
             Class<?> fieldType = field.getType();
-            if (fieldConfAnnotation != null) {
-                if (ConfigurationUtils.isAPrimitiveOrWrapper(fieldType) ||
-                        ConfigurationUtils.isAPrimitivesOrWrappersArray(fieldType)) {
-                    setPrimitiveField(field, objToReturn, tenant, namespace, keyPrefix, hints);
-                }
-                if (ConfigurationUtils.isACollection(fieldType)) {
-                    setCollectionField(field, objToReturn, tenant, namespace, keyPrefix, hints);
-                }
-                if (ConfigurationUtils.isAMap(fieldType)) {
-                    setMapField(field, objToReturn, tenant, namespace, keyPrefix);
-                }
+            if (fieldConfAnnotation == null) {
+                continue;
+            }
+            if (ConfigurationUtils.isAPrimitiveOrWrapper(fieldType) ||
+                ConfigurationUtils.isAPrimitivesOrWrappersArray(fieldType)) {
+                setPrimitiveField(field, objToReturn, tenant, namespace, keyPrefix, hints);
+            }
+            if (ConfigurationUtils.isACollection(fieldType)) {
+                setCollectionField(field, objToReturn, tenant, namespace, keyPrefix, hints);
+            }
+            if (ConfigurationUtils.isAMap(fieldType)) {
+                setMapField(field, objToReturn, tenant, namespace, keyPrefix);
             }
         }
         return objToReturn;
@@ -471,30 +472,31 @@
         Object obj = get(tenant, namespace, keyPrefix + fieldConfAnnotationKey,
                 ConfigurationUtils.getArrayClass(ConfigurationUtils.getCollectionGenericType(field)),
                 hints);
-        if (obj != null) {
-            List<Object> list = Arrays.asList((Object[]) obj);
-            Class clazzToInstantiate;
-            if (fieldType.isInterface()) {
-                clazzToInstantiate = ConfigurationUtils.getConcreteCollection(fieldType).getClass();
-            } else if (Modifier.isAbstract(fieldType.getModifiers())) {
-                clazzToInstantiate =
-                        ConfigurationUtils.getCompatibleCollectionForAbstractDef(fieldType)
-                                .getClass();
-            } else {
-                clazzToInstantiate = fieldType;
-            }
-            Constructor construct = getConstructorWithArguments(clazzToInstantiate, Collection.class);
+        if (obj == null) {
+            return;
+        }
+        List<Object> list = Arrays.asList((Object[]) obj);
+        Class clazzToInstantiate;
+        if (fieldType.isInterface()) {
+            clazzToInstantiate = ConfigurationUtils.getConcreteCollection(fieldType).getClass();
+        } else if (Modifier.isAbstract(fieldType.getModifiers())) {
+            clazzToInstantiate =
+                    ConfigurationUtils.getCompatibleCollectionForAbstractDef(fieldType)
+                            .getClass();
+        } else {
+            clazzToInstantiate = fieldType;
+        }
+        Constructor construct = getConstructorWithArguments(clazzToInstantiate, Collection.class);
 
+        if (construct != null) {
+            construct.setAccessible(true);
+            field.set(objToReturn, construct.newInstance(list));
+        } else {
+            construct = getConstructorWithArguments(clazzToInstantiate, Integer.class,
+                   Boolean.class, Collection.class);
             if (construct != null) {
                 construct.setAccessible(true);
-                field.set(objToReturn, construct.newInstance(list));
-            } else {
-                construct = getConstructorWithArguments(clazzToInstantiate, Integer.class,
-                        Boolean.class, Collection.class);
-                if (construct != null) {
-                    construct.setAccessible(true);
-                    field.set(objToReturn, construct.newInstance(list.size(), true, list));
-                }
+                field.set(objToReturn, construct.newInstance(list.size(), true, list));
             }
         }
     }
