Uploaded image for project: 'netconf'
  1. netconf
  2. NETCONF-607

RPC with no input throw NPE when called via Restconf

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Highest Highest
    • Neon, Fluorine SR3, Sodium
    • Neon, Fluorine SR2, Sodium
    • restconf-nb
    • None

      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 ''

       

            JMorvay Jakub Morvay
            rkosegi Richard Kosegi
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: