Uploaded image for project: 'Service Orchestrator'
  1. Service Orchestrator
  2. SO-1438

@Autowired doesn't work if object is created by "new"

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Do
    • Icon: Medium Medium
    • Dublin Release
    • Dublin Release, Casablanca Maintenance Release
    • CMCC LAB

      UUI get 500 response code instead of 400 for the exception below:

      2019-01-30T07:01:48.800Z|8ce81962-2ec9-49c4-a09e-09cb78c501e8|http-nio-8080-exec-1|onap/so/infra/e2eServiceInstances/v5||||ERROR|||null2019-01-30T07:01:48.800Z|8ce81962-2ec9-49c4-a09e-09cb78c501e8|http-nio-8080-exec-1|onap/so/infra/e2eServiceInstances/v5||||ERROR|||nulljava.lang.NullPointerException: null at org.onap.so.apihandlerinfra.MsoRequest.buildServiceErrorResponse(MsoRequest.java:151) at org.onap.so.apihandlerinfra.E2EServiceInstances.processE2EserviceInstances(E2EServiceInstances.java:702) at org.onap.so.apihandlerinfra.E2EServiceInstances.createE2EServiceInstance(E2EServiceInstances.java:123)

       

      Analysis shows below:

       

      so\mso-api-handlers\mso-api-handler-infra\src\main\java\org\onap\so\apihandlerinfra\MsoRequest.java

      line 102:

      @Autowired
      private ResponseBuilder builder; // builder object created by @Autowired

      line 151:

      return builder.buildResponse(httpResponseCode, null, requestErrorStr, version); // using builder object

       

      so\mso-api-handlers\mso-api-handler-infra\src\main\java\org\onap\so\apihandlerinfra\E2EServiceInstances.java

      line 694:

      MsoRequest msoRequest = new MsoRequest(); // created by new, and @Autowired doesn't work in MsoRequest, builder will be null.

      line 702:

      Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_REQUEST,
      MsoException.ServiceException, "Mapping of request to JSON object failed. " + e.getMessage(),
      ErrorNumbers.SVC_BAD_PARAMETER, null, version);  // invoke  buildServiceErrorResponse() will raise a null exception for builder is null.

       

       

            subhash_singh subhash_singh
            sonicke sonicke
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: