bug 152 47/2847/1
authorDavid Bainbridge <dbainbri@ciena.com>
Mon, 18 Nov 2013 22:38:17 +0000 (14:38 -0800)
committerDavid Bainbridge <dbainbri@ciena.com>
Mon, 18 Nov 2013 22:41:43 +0000 (14:41 -0800)
add a null check when setting delgates, as when implementations are unregistered, registrations are closed, the delegate is set to null. this was causing a null pointer exception.

Change-Id: Ib37937cee768ba03c61154cc227316d6aef69cb8
Signed-off-by: David Bainbridge <dbainbri@ciena.com>
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/RuntimeCodeHelper.xtend

index fbd87d1..f0f92da 100644 (file)
@@ -39,7 +39,7 @@ class RuntimeCodeHelper {
     public static def void setDelegate(RpcService proxy, RpcService delegate) {
         val field = proxy.class.getField(DELEGATE_FIELD)
         if (field == null) throw new UnsupportedOperationException("Unable to set delegate to proxy");
-        if (field.type.isAssignableFrom(delegate.class)) {
+        if (delegate == null || field.type.isAssignableFrom(delegate.class)) {
             field.set(proxy, delegate)
         } else
             throw new IllegalArgumentException("delegate class is not assignable to proxy");
@@ -55,7 +55,7 @@ class RuntimeCodeHelper {
     public static def void setDelegate(Object proxy, Object delegate) {
         val field = proxy.class.getField(DELEGATE_FIELD)
         if (field == null) throw new UnsupportedOperationException("Unable to set delegate to proxy");
-        if (field.type.isAssignableFrom(delegate.class)) {
+        if (delegate == null || field.type.isAssignableFrom(delegate.class)) {
             field.set(proxy, delegate)
         } else
             throw new IllegalArgumentException("delegate class is not assignable to proxy");

©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.