Merge "Reorder modifiers"
[so.git] / adapters / mso-adapter-utils / src / main / java / org / openecomp / mso / cloud / CloudConfigFactory.java
index 9f6520c..2b38591 100644 (file)
@@ -57,13 +57,13 @@ public class CloudConfigFactory implements Serializable {
 
     private static final long serialVersionUID = 2956662716453261085L;
 
-    private CloudConfig cloudConfigCache = new CloudConfig();
+    private static CloudConfig cloudConfigCache = new CloudConfig();
 
     protected static String prefixMsoPropertiesPath = System.getProperty ("mso.config.path");
 
     private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA);
 
-    private int refreshTimer;
+    private static int refreshTimer;
 
     private static final ReentrantReadWriteLock rwl = new ReentrantReadWriteLock ();
 
@@ -72,7 +72,7 @@ public class CloudConfigFactory implements Serializable {
             prefixMsoPropertiesPath = "";
         }
     }
-
+    
     public void initializeCloudConfig (String filePath, int refreshTimer) throws MsoCloudIdentityNotFound {
         rwl.writeLock ().lock ();
         try {
@@ -92,11 +92,11 @@ public class CloudConfigFactory implements Serializable {
     public CloudConfig getCloudConfig () {
         rwl.readLock ().lock ();
         try {
-            if (cloudConfigCache.isValidCloudConfig()) {
-                return cloudConfigCache.clone ();
-            } else {
-                return new CloudConfig();
+            if (!cloudConfigCache.isValidCloudConfig()) {
+               // Not ideal, but better than returning an invalid object
+               throw new IllegalStateException("No valid CloudConfig is loaded");
             }
+            return cloudConfigCache.clone ();
         } finally {
             rwl.readLock ().unlock ();
         }
@@ -105,8 +105,6 @@ public class CloudConfigFactory implements Serializable {
     /**
      * This method is not intended to be called, it's used to refresh the config
      * automatically
-     *
-     * @return true if Properties have been reloaded, false otherwise
      */
     @Schedule(minute = "*/1", hour = "*", persistent = false)
     public void reloadCloudConfig () {