MDSAL-294: Binding v1 generator - Add @CheckReturnValue on RPC methods 63/65063/5
authorJie Han <han.jie@zte.com.cn>
Fri, 3 Nov 2017 01:05:09 +0000 (09:05 +0800)
committerRobert Varga <robert.varga@pantheon.tech>
Mon, 6 Nov 2017 23:54:03 +0000 (00:54 +0100)
-  Use @CheckReturnValue annotation in static code analysis
to ensure that all users of the RPC do check the Future RpcResult
 for errors - even if there is no Output.

Change-Id: I7b4e5f0d7ca81db154a39325490a46bfcf8820a4
Signed-off-by: Jie Han <han.jie@zte.com.cn>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/mdsal/binding/generator/impl/BindingGeneratorImpl.java

index 853fad8536d6879e74ccec4fee7e3d40cea55b50..f6bb3c5f630af4f8ab74ca573188cd5e77afd0c1 100644 (file)
@@ -510,6 +510,9 @@ public class BindingGeneratorImpl implements BindingGenerator {
                 final ContainerSchemaNode input = rpc.getInput();
                 final ContainerSchemaNode output = rpc.getOutput();
 
+                // Do not refer to annotation class, as it may not be available at runtime
+                method.addAnnotation("javax.annotation", "CheckReturnValue");
+
                 //in case of implicit RPC input (StatementSource.CONTEXT),
                 // stay compatible (no input argument generated)
                 if (input != null && isExplicitStatement(input)) {