From ac724b45d8234d507a681123f460b25d5d4f4499 Mon Sep 17 00:00:00 2001 From: David Bainbridge Date: Mon, 18 Nov 2013 14:38:17 -0800 Subject: [PATCH] bug 152 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 --- .../controller/sal/binding/codegen/RuntimeCodeHelper.xtend | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/RuntimeCodeHelper.xtend b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/RuntimeCodeHelper.xtend index fbd87d17be..f0f92da18e 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/RuntimeCodeHelper.xtend +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/RuntimeCodeHelper.xtend @@ -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"); -- 2.36.6