Bug 2233 - RPC register exception when rpc has no input 01/12401/1
authorJan Hajnar <jhajnar@cisco.com>
Fri, 31 Oct 2014 12:59:08 +0000 (13:59 +0100)
committerJan Hajnar <jhajnar@cisco.com>
Fri, 31 Oct 2014 12:59:08 +0000 (13:59 +0100)
* added check that should prevent non routed Rpcs being treated as
routed and and failing at context resolution.

Change-Id: I281152879429f2020f48894753f1d57aea85bde6
Signed-off-by: Jan Hajnar <jhajnar@cisco.com>
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/impl/AbstractRuntimeCodeGenerator.java

index 1fa54be..eba5b87 100644 (file)
@@ -8,17 +8,11 @@
 package org.opendaylight.controller.sal.binding.codegen.impl;
 
 import com.google.common.base.Supplier;
-
-import java.util.Map;
-import java.util.WeakHashMap;
-
+import com.google.common.collect.Iterables;
 import javassist.ClassPool;
 import javassist.CtClass;
 import javassist.CtMethod;
 import javassist.NotFoundException;
-
-import javax.annotation.concurrent.GuardedBy;
-
 import org.eclipse.xtext.xbase.lib.Extension;
 import org.opendaylight.controller.sal.binding.api.rpc.RpcRouter;
 import org.opendaylight.controller.sal.binding.codegen.RpcIsNotRoutedException;
@@ -31,6 +25,10 @@ import org.opendaylight.yangtools.yang.binding.RpcService;
 import org.opendaylight.yangtools.yang.binding.annotations.RoutingContext;
 import org.opendaylight.yangtools.yang.binding.util.ClassLoaderUtils;
 
+import javax.annotation.concurrent.GuardedBy;
+import java.util.Map;
+import java.util.WeakHashMap;
+
 abstract class AbstractRuntimeCodeGenerator implements org.opendaylight.controller.sal.binding.codegen.RuntimeCodeGenerator, NotificationInvokerFactory {
     @GuardedBy("this")
     private final Map<Class<? extends NotificationListener>, RuntimeGeneratedInvokerPrototype> invokerClasses = new WeakHashMap<>();
@@ -174,6 +172,10 @@ abstract class AbstractRuntimeCodeGenerator implements org.opendaylight.controll
             }
         });
 
+        if (Iterables.isEmpty(metadata.getContexts())) {
+            throw new RpcIsNotRoutedException("Service doesn't have routing context associated.");
+        }
+
         synchronized (utils) {
             final T instance = ClassLoaderUtils.withClassLoader(serviceType.getClassLoader(), routerSupplier(serviceType, metadata));
             return new RpcRouterCodegenInstance<T>(name, serviceType, instance, metadata.getContexts());

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.