Merge "Backward compatibility change for Configuration Service"
authorGiovanni Meo <gmeo@cisco.com>
Wed, 29 Jan 2014 05:37:30 +0000 (05:37 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Wed, 29 Jan 2014 05:37:30 +0000 (05:37 +0000)
opendaylight/configuration/implementation/src/main/java/org/opendaylight/controller/configuration/internal/ConfigurationService.java
opendaylight/configuration/implementation/src/main/java/org/opendaylight/controller/configuration/internal/ContainerConfigurationService.java

index 03acfa88eb04e1737650af810c11b1afe809ad88..e4d55d11fb39e126d2dbb99f0ceb0cb6672d7069 100644 (file)
@@ -9,6 +9,7 @@
 
 package org.opendaylight.controller.configuration.internal;
 
+import java.util.ArrayList;
 import java.util.Collections;
 import java.util.EnumSet;
 import java.util.HashSet;
@@ -189,7 +190,12 @@ public class ConfigurationService implements IConfigurationService, ICacheUpdate
         }
         String source = String.format("%s%s", ROOT, fileName);
         Object obj = objReader.read(reader, source);
-        return (obj == null || !(obj instanceof List)) ? Collections.<ConfigurationObject> emptyList()
-                : (List<ConfigurationObject>) obj;
+        if (obj == null) {
+            return Collections.<ConfigurationObject> emptyList();
+        }
+        if (obj instanceof ConcurrentMap) {
+            return new ArrayList<ConfigurationObject>(((ConcurrentMap)obj).values());
+        }
+        return (List<ConfigurationObject>) obj;
     }
 }
index c33fdefd7b4a87b9da85548054e7936cbfdccb9f..9c1d391daa7b8e80eec73ce454e30a6b768efe4d 100644 (file)
@@ -10,6 +10,7 @@
 package org.opendaylight.controller.configuration.internal;
 
 import java.io.File;
+import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Dictionary;
 import java.util.EnumSet;
@@ -219,7 +220,12 @@ public class ContainerConfigurationService implements IConfigurationContainerSer
         }
         String source = String.format("%s%s", root, fileName);
         Object obj = objReader.read(reader, source);
-        return (obj == null || !(obj instanceof List)) ? Collections.<ConfigurationObject> emptyList()
-                : (List<ConfigurationObject>) obj;
+        if (obj == null) {
+            return Collections.<ConfigurationObject> emptyList();
+        }
+        if (obj instanceof ConcurrentMap) {
+            return new ArrayList<ConfigurationObject>(((ConcurrentMap)obj).values());
+        }
+        return (List<ConfigurationObject>) obj;
     }
 }