Uploaded image for project: 'External API Framework'
  1. External API Framework
  2. EXTAPI-69

NPE on NBI serviceInventory for service without VNF

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: High High
    • Beijing Release
    • Beijing Release
    • None
    • None

      Following NPE occurs when fetching service details for a given service Id with the serviceInventory NBI API when service has no relationship to resources, which is the case right after the creation of the service with NBI (and before VID or REST API are used to create VNF/VFmodules or network)

      java.lang.NullPointerException: null
      at org.onap.nbi.apis.serviceinventory.ServiceInventoryService.addVnfsToResponse(ServiceInventoryService.java:90) ~[classes!/:1.0.0-SNAPSHOT]
      at org.onap.nbi.apis.serviceinventory.ServiceInventoryService.get(ServiceInventoryService.java:46) ~[classes!/:1.0.0-SNAPSHOT]
      at org.onap.nbi.apis.serviceinventory.ServiceInventoryResource.getServiceInventory(ServiceInventoryResource.java:28) ~[classes!/:1.0.0-SNAPSHOT]
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_121]
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_121]
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_121]
      at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_121]
      at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205) ~[spring-web-4.3.14.RELEASE.jar!/:4.3.14.RELEASE]
      at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:133) ~[spring-web-4.3.14.RELEASE.jar!/:4.3.14.RELEASE]
      at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:97) ~[spring-webmvc-4.3.14.RELEASE.jar!/:4.3.14.RELEASE]
      at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827) ~[spring-webmvc-4.3.14.RELEASE.jar!/:4.3.14.RELEASE]
      at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738) ~[spring-webmvc-4.3.14.RELEASE.jar!/:4.3.14.RELEASE]

      ...

      Note that the same NPE happens when trying to delete the service using NBI since a inventory lookup is done before deletion.

      Problem is with this file :

      src/main/java/org/onap/nbi/apis/serviceinventory/ServiceInventoryService.java

      We should add a check if relationship-list is present under the service-instance to avoid the NPE :

      private void addVnfsToResponse(LinkedHashMap serviceResponse) {

              List<LinkedHashMap> vnfs = new ArrayList<>();

              LinkedHashMap relationShip = (LinkedHashMap) serviceResponse.get("relationship-list");

              List<LinkedHashMap> relationsList = (List<LinkedHashMap>) relationShip.get("relationship");

            romaingimbert romaingimbert
            chiarelloa chiarelloa
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: