[NETCONF-365] NPE when posting using XML Created: 08/Mar/17  Updated: 15/Mar/19  Resolved: 10/Jun/17

Status: Resolved
Project: netconf
Component/s: restconf-nb
Affects Version/s: None
Fix Version/s: None

Type: Bug
Reporter: Claudio David Gasparini Assignee: Matúš Kubica
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Operating System: All
Platform: All


External issue ID: 7933

 Description   

During test under bgp observed that

doing

Put
http://localhost:8181/restconf/config/bgp-linkstate-app-config:bgp-linkstate-app-config

<iana-linkstate-attribute-type xmlns="urn:opendaylight:params:xml:ns:yang:controller:bgp:linkstate-app-config">false</iana-linkstate-attribute-type>

Will behave as expected.

Then if we proceed to check the stored information

Get
http://localhost:8181/restconf/config/bgp-linkstate-app-config:bgp-linkstate-app-config

<errors xmlns="urn:ietf:params:xml:ns:yang:ietf-restconf">
<error>
<error-type>application</error-type>
<error-tag>data-missing</error-tag>
<error-message>Request could not be completed because the relevant data model content does not exist </error-message>
</error>
</errors>

Also if we try to do an update through

Post
http://localhost:8181/restconf/config/bgp-linkstate-app-config:bgp-linkstate-app-config

<iana-linkstate-attribute-type xmlns="urn:opendaylight:params:xml:ns:yang:controller:bgp:linkstate-app-config">true</iana-linkstate-attribute-type>

will end on

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
<title>Error 500 Server Error</title>
</head>
<body>
<h2>HTTP ERROR 500</h2>
<p>Problem accessing /restconf/config/bgp-linkstate-app-config:bgp-linkstate-app-config. Reason:

<pre> Server Error</pre>
</p>
<h3>Caused by:</h3>
<pre>java.lang.NullPointerException
at org.opendaylight.controller.cluster.databroker.AbstractDOMBrokerWriteTransaction.checkInstanceIdentifierReferencesData(AbstractDOMBrokerWriteTransaction.java:87)
at org.opendaylight.controller.cluster.databroker.AbstractDOMBrokerWriteTransaction.put(AbstractDOMBrokerWriteTransaction.java:79)
at org.opendaylight.netconf.sal.restconf.impl.BrokerFacade.simplePostPut(BrokerFacade.java:884)
at org.opendaylight.netconf.sal.restconf.impl.BrokerFacade.makeNormalPost(BrokerFacade.java:876)
at org.opendaylight.netconf.sal.restconf.impl.BrokerFacade.postData(BrokerFacade.java:682)
at org.opendaylight.netconf.sal.restconf.impl.BrokerFacade.postDataViaTransaction(BrokerFacade.java:664)
at org.opendaylight.netconf.sal.restconf.impl.BrokerFacade.commitConfigurationDataPost(BrokerFacade.java:454)
at org.opendaylight.netconf.sal.restconf.impl.RestconfImpl.createConfigurationData(RestconfImpl.java:998)
at org.opendaylight.netconf.sal.restconf.impl.RestconfImpl.createConfigurationData(RestconfImpl.java:914)
at org.opendaylight.netconf.sal.restconf.impl.StatisticsRestconfServiceWrapper.createConfigurationData(StatisticsRestconfServiceWrapper.java:156)
at org.opendaylight.netconf.sal.rest.impl.RestconfCompositeWrapper.createConfigurationData(RestconfCompositeWrapper.java:92)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60)
at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$ResponseOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:205)
at com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75)
at com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:302)
at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
at com.sun.jersey.server.impl.uri.rules.ResourceObjectRule.accept(ResourceObjectRule.java:100)
at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
at com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84)
at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1511)
at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1442)
at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1391)
at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1381)
at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:416)
at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:538)
at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:716)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:668)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:684)

Updated Model

module bgp-linkstate-app-config {
yang-version 1;
namespace "urn:opendaylight:params:xml:ns:yang:controller:bgp:linkstate-app-config";
prefix "bgp-linkstate-app-config";

description
"Configuration for the BGP linkstate application.";

revision "2016-06-14"

{ description "Initial revision."; }

container bgp-linkstate-app-config {
leaf iana-linkstate-attribute-type

{ description "If true (default) linkstate attribute type (=29) allocated by IANA is used, else type (=99) is used for parsing/serialization"; type boolean; default true; }

}
}



 Comments   
Comment by Robert Varga [ 14/Mar/17 ]

The problem is that for some reason NormalizedNodeContext is initialized with null data.

Comment by Ivan Hrasko [ 05/May/17 ]

Hint:
Please note that second operation is POST (first was PUT).
In general when doing POST different data should be used than with PUT.

Comment by Matúš Kubica [ 10/May/17 ]

PUT
http://localhost:8181/restconf/config/instance-identifier-patch-module:bgp-linkstate-app-config

works with correctly formed body:

<bgp-linkstate-app-config xmlns="instance:identifier:patch:module">
<iana-linkstate-attribute-type>false</iana-linkstate-attribute-type>
</bgp-linkstate-app-config>

Then there is also possibility to perform GET succesfully.

Comment by Robert Varga [ 10/May/17 ]

Well, malformed request should not be causing a NPE nor a 500 response, but rather indicate what's wrong with the request...

Comment by Ivan Hrasko [ 19/May/17 ]

Prevent NPE with POST when data is leaf:
https://git.opendaylight.org/gerrit/#/c/57425

Comment by Ivan Hrasko [ 23/May/17 ]

Prevent not well formatted PUT: https://git.opendaylight.org/gerrit/#/c/57362

Comment by Ivan Hrasko [ 23/May/17 ]

carbon:
https://git.opendaylight.org/gerrit/#/c/57684/
https://git.opendaylight.org/gerrit/#/c/57683/

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