[NETCONF-607] RPC with no input throw NPE when called via Restconf Created: 08/Feb/19  Updated: 21/Feb/19  Resolved: 21/Feb/19

Status: Resolved
Project: netconf
Component/s: restconf-nb
Affects Version/s: Neon, Fluorine SR2, Sodium
Fix Version/s: Neon, Fluorine SR3, Sodium

Type: Bug Priority: Highest
Reporter: Richard Kosegi Assignee: Jakub Morvay
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

Given RPC (no input):

    rpc force-refresh {                           
        output {                                  
            leaf result

{                                          type boolean;                                      description "Refresh operation result - true if successful, false otherwise.";             }

                                     
        }                                         
    }

when called via restconf like this:

curl -u admin:admin -X POST -v  http://localhost:8181/restconf/operations/jsonrpc:force-refresh

Leads to following error:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<title>Error 500 Request failed.</title>
</head>
<body><h2>HTTP ERROR 500</h2>
<p>Problem accessing /restconf/operations/jsonrpc:force-refresh. Reason:
<pre>    Request failed.</pre></p>
</body>
</html>

 

Karaf log indicates NPE:

Caused by: java.lang.NullPointerException
    at org.opendaylight.netconf.sal.restconf.impl.RestconfImpl.invokeRpc(RestconfImpl.java:426) ~[?:?]
    at org.opendaylight.netconf.sal.restconf.impl.StatisticsRestconfServiceWrapper.invokeRpc(StatisticsRestconfServiceWrapper.java:83) ~[?:?]
    at org.opendaylight.netconf.sal.rest.impl.RestconfCompositeWrapper.invokeRpc(RestconfCompositeWrapper.java:64) ~[?:?]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAc

 

Can we add check and throw RestconfDocumentedException so user will know that required input is missing?

eg. this works

curl -u admin:admin -X POST  http://localhost:8181/restconf/operations/jsonrpc:force-refresh -d ''

 



 Comments   
Comment by Richard Kosegi [ 08/Feb/19 ]

Maybe this is regression? https://jira.opendaylight.org/browse/NETCONF-509

Generated at Wed Feb 07 20:15:27 UTC 2024 using Jira 8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d.