BUG-4167: fall back to unknown module for empty YangInstanceIdentifier 87/41887/2
authorRobert Varga <rovarga@cisco.com>
Fri, 15 Jul 2016 10:43:58 +0000 (12:43 +0200)
committerRobert Varga <nite@hq.sk>
Mon, 18 Jul 2016 08:43:56 +0000 (08:43 +0000)
When we encounter an empyt YangInstanceIdentifier (for
example during listener registration), we cannot extract
a module name -- fallback to unknown, which will cause
us to talk to the default shard.

Change-Id: I2162884c5ce0d2c2f714bb66afd82f699c52d789
Signed-off-by: Robert Varga <rovarga@cisco.com>
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardstrategy/ShardStrategyFactory.java

index 1a5a4ac..8ca6150 100644 (file)
@@ -44,6 +44,10 @@ public class ShardStrategyFactory {
     }
 
     private String getModuleName(final YangInstanceIdentifier path) {
+        if (path.isEmpty()) {
+            return UNKNOWN_MODULE_NAME;
+        }
+
         String namespace = path.getPathArguments().iterator().next().getNodeType().getNamespace().toASCIIString();
         String moduleName = configuration.getModuleNameFromNameSpace(namespace);
         return moduleName != null ? moduleName : UNKNOWN_MODULE_NAME;