provide missing module's name via IllegalArgumentException 42/73442/2
authorMichael Vorburger <vorburger@redhat.com>
Tue, 26 Jun 2018 11:09:37 +0000 (13:09 +0200)
committerTom Pantelis <tompantelis@gmail.com>
Tue, 26 Jun 2018 13:17:14 +0000 (13:17 +0000)
by using orElseThrow() instead of get() on Optional<Module> in RpcUtil

to help understand MDSAL-354 problem

JIRA: MDSAL-354
Change-Id: If4d4f663b7cb63acea38acda73686176d27ff56f
Signed-off-by: Michael Vorburger <vorburger@redhat.com>
opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/RpcUtil.java

index 9dbd019676f919db3bc8d7bd6939b7822aed7179..8f9e4ef6b221ffe97fab0d7d22804055ae5a73c3 100644 (file)
@@ -36,7 +36,8 @@ final class RpcUtil {
     static Collection<SchemaPath> decomposeRpcService(final Class<RpcService> service,
             final SchemaContext schemaContext, final Predicate<RpcRoutingStrategy> filter) {
         final QNameModule moduleName = BindingReflections.getQNameModule(service);
-        final Module module = schemaContext.findModule(moduleName).get();
+        final Module module = schemaContext.findModule(moduleName).orElseThrow(() -> new IllegalArgumentException(
+                "Module not found in SchemaContext: " + moduleName + "; service: " + service));
         LOG.debug("Resolved service {} to module {}", service, module);
 
         final Collection<RpcDefinition> rpcs = module.getRpcs();