From: Tony Tkacik Date: Thu, 12 Mar 2015 11:04:09 +0000 (+0000) Subject: Merge "Quick fix nullable RPC input" X-Git-Tag: release/lithium~413 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=4c4cab643ce6aeb5b60cb9b1b1e193c4fafb46ad;hp=9db24f2b887db47a63e56579ecdd6839b0a31b55 Merge "Quick fix nullable RPC input" --- diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMRpcImplementationAdapter.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMRpcImplementationAdapter.java index d76d4f9bba..c4a99efdbe 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMRpcImplementationAdapter.java +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMRpcImplementationAdapter.java @@ -50,8 +50,8 @@ public class BindingDOMRpcImplementationAdapter implements DOMRpcImplementation public BindingDOMRpcImplementationAdapter(final BindingNormalizedNodeCodecRegistry codec, final Class type ,final T delegate) { this.codec = codec; this.delegate = delegate; - this.invoker = RpcServiceInvoker.from(type); - this.module = BindingReflections.getQNameModule(type); + invoker = RpcServiceInvoker.from(type); + module = BindingReflections.getQNameModule(type); } public QNameModule getQNameModule() { @@ -61,7 +61,7 @@ public class BindingDOMRpcImplementationAdapter implements DOMRpcImplementation @Override public CheckedFuture invokeRpc(final DOMRpcIdentifier rpc, final NormalizedNode input) { final SchemaPath schemaPath = rpc.getType(); - final DataObject bindingInput = deserilialize(rpc.getType(),input); + final DataObject bindingInput = input != null ? deserilialize(rpc.getType(),input) : null; final ListenableFuture> bindingResult = invoke(schemaPath,bindingInput); return transformResult(schemaPath,bindingResult); } diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingRpcImplementationAdapter.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingRpcImplementationAdapter.java index 9f0de746e6..25a6ebde97 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingRpcImplementationAdapter.java +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingRpcImplementationAdapter.java @@ -12,6 +12,7 @@ import com.google.common.util.concurrent.CheckedFuture; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.JdkFutureAdapters; import com.google.common.util.concurrent.ListenableFuture; +import javax.annotation.Nullable; import org.opendaylight.controller.md.sal.dom.api.DOMRpcException; import org.opendaylight.controller.md.sal.dom.api.DOMRpcIdentifier; import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementation; @@ -33,7 +34,7 @@ public class BindingRpcImplementationAdapter implements DOMRpcImplementation { private static final Function EXCEPTION_MAPPER = new Function() { @Override - public DOMRpcException apply(Exception input) { + public DOMRpcException apply(final Exception input) { // FIXME: Return correct exception return null; } @@ -44,7 +45,7 @@ public class BindingRpcImplementationAdapter implements DOMRpcImplementation { private final RpcService delegate; private final QNameModule module; - private Function,DOMRpcResult> lazySerializedMapper = new Function,DOMRpcResult>() { + private final Function,DOMRpcResult> lazySerializedMapper = new Function,DOMRpcResult>() { @Override public DOMRpcResult apply(final RpcResult input) { @@ -52,11 +53,11 @@ public class BindingRpcImplementationAdapter implements DOMRpcImplementation { } }; - public BindingRpcImplementationAdapter(BindingNormalizedNodeCodecRegistry codec, Class type ,T delegate) { + public BindingRpcImplementationAdapter(final BindingNormalizedNodeCodecRegistry codec, final Class type ,final T delegate) { this.codec = codec; this.delegate = delegate; - this.invoker = RpcServiceInvoker.from(type); - this.module = BindingReflections.getQNameModule(type); + invoker = RpcServiceInvoker.from(type); + module = BindingReflections.getQNameModule(type); } public QNameModule getQNameModule() { @@ -64,29 +65,29 @@ public class BindingRpcImplementationAdapter implements DOMRpcImplementation { } @Override - public CheckedFuture invokeRpc(DOMRpcIdentifier rpc, NormalizedNode input) { - SchemaPath schemaPath = rpc.getType(); - DataObject bindingInput = deserilialize(rpc.getType(),input); - ListenableFuture> bindingResult = invoke(schemaPath,bindingInput); + public CheckedFuture invokeRpc(final DOMRpcIdentifier rpc, @Nullable final NormalizedNode input) { + final SchemaPath schemaPath = rpc.getType(); + final DataObject bindingInput = input != null ? deserilialize(rpc.getType(),input) : null; + final ListenableFuture> bindingResult = invoke(schemaPath, bindingInput); return transformResult(schemaPath,bindingResult); } - private DataObject deserilialize(SchemaPath rpcPath, NormalizedNode input) { + private DataObject deserilialize(final SchemaPath rpcPath, final NormalizedNode input) { if(input instanceof LazySerializedContainerNode) { return ((LazySerializedContainerNode) input).bindingData(); } - SchemaPath inputSchemaPath = rpcPath.createChild(QName.create(module,"input")); + final SchemaPath inputSchemaPath = rpcPath.createChild(QName.create(module,"input")); return codec.fromNormalizedNodeRpcData(inputSchemaPath, (ContainerNode) input); } - private ListenableFuture> invoke(SchemaPath schemaPath, DataObject input) { + private ListenableFuture> invoke(final SchemaPath schemaPath, final DataObject input) { return JdkFutureAdapters.listenInPoolThread(invoker.invokeRpc(delegate, schemaPath.getLastComponent(), input)); } - private CheckedFuture transformResult(SchemaPath schemaPath, - ListenableFuture> bindingResult) { - ListenableFuture transformed = Futures.transform(bindingResult, lazySerializedMapper); + private CheckedFuture transformResult(final SchemaPath schemaPath, + final ListenableFuture> bindingResult) { + final ListenableFuture transformed = Futures.transform(bindingResult, lazySerializedMapper); return Futures.makeChecked(transformed, EXCEPTION_MAPPER); }