From: Ed Warnicke Date: Sat, 23 Aug 2014 19:56:17 +0000 (-0500) Subject: Bug 1514: Correctly handle ModuleOrModuleBuilder in ModuleDependencySort X-Git-Tag: release/helium~182 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=fa0be1f641cd46486c99007a8d6c8279e683185f;p=yangtools.git Bug 1514: Correctly handle ModuleOrModuleBuilder in ModuleDependencySort ModuleDependencySort.processDependencies(...) Turns out allNS.get(ns) can return objects of type ModuleOrModuleBuilder (not just Module or ModuleBuilder types). Now we check for that case, and unpack it to a Module or ModuleBuilder. The rest of the logic then continues as normal. Also added a log for getting a module with no name so as to catch similar issues in the future. Change-Id: I956c334c5dd10b51bec01d409f2433229d05f767 Signed-off-by: Ed Warnicke --- diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/util/ModuleDependencySort.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/util/ModuleDependencySort.java index 7b543b7307..051dd4f727 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/util/ModuleDependencySort.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/util/ModuleDependencySort.java @@ -178,12 +178,25 @@ public final class ModuleDependencySort { Object mod = allNS.get(ns); String name = null; Date revision = null; + + if(mod instanceof ModuleOrModuleBuilder) { + ModuleOrModuleBuilder modOrmodBuilder = ((ModuleOrModuleBuilder) mod); + if(modOrmodBuilder.isModule()) { + mod = ((ModuleOrModuleBuilder) mod).getModule(); + } else if (modOrmodBuilder.isModuleBuilder()) { + mod = ((ModuleOrModuleBuilder) mod).getModuleBuilder(); + } else { + LOGGER.warn("ModuleOrModuleBuilder is neither Module or ModuleBuilder"); + } + } if (mod instanceof Module) { name = ((Module) mod).getName(); revision = ((Module) mod).getRevision(); } else if (mod instanceof ModuleBuilder) { name = ((ModuleBuilder) mod).getName(); revision = ((ModuleBuilder) mod).getRevision(); + } else { + LOGGER.warn("Module has no name: {}", mod); } if (!(fromName.equals(name))) { LOGGER.warn(