Fix Sonar violations - AggregateConfiguration 59/27059/2
authorojasdubey <ojas.dubey@amdocs.com>
Wed, 27 Dec 2017 14:38:14 +0000 (20:08 +0530)
committerVitaly Emporopulo <Vitaliy.Emporopulo@amdocs.com>
Wed, 27 Dec 2017 15:40:27 +0000 (15:40 +0000)
1. Fixed major sonar violations configuration management core
- AggregateConfiguration

Change-Id: I311d0e84fbfaf936ec1a260898e0cc0090e05be9
Issue-ID: SDC-343
Signed-off-by: ojasdubey <ojas.dubey@amdocs.com>
common/openecomp-common-configuration-management/openecomp-configuration-management-core/src/main/java/org/openecomp/config/impl/AggregateConfiguration.java

index de5a189..e67de75 100644 (file)
@@ -24,10 +24,18 @@ public final class AggregateConfiguration {
   private Map<String, Configuration> mergeConfig = new HashMap<>();
   private Map<String, Configuration> overrideConfig = new LinkedHashMap<>();
 
-  {
-    if (!Thread.currentThread().getStackTrace()[2].getClassName()
-        .equals(ConfigurationImpl.class.getName())) {
-      throw new RuntimeException("Illegal access.");
+  /**
+   * Instantiates a new Aggregate configuration.
+   */
+  public AggregateConfiguration() {
+    try {
+      Class clazz = Class.forName(Thread.currentThread().getStackTrace()[2].getClassName());
+      if (!clazz.getCanonicalName()
+          .equals(ConfigurationImpl.class.getCanonicalName())) {
+        throw new RuntimeException("Illegal access.");
+      }
+    } catch (ClassNotFoundException cfe) {
+      throw new RuntimeException("Class not found while loading change notifier");
     }
   }