Uploaded image for project: 'Configuration Persistence Service'
  1. Configuration Persistence Service
  2. CPS-955

Fix exception handling in case of 2XX HTTP response code

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Medium Medium
    • Jakarta Release
    • Jakarta Release
    • DMI, NCMP
    • None

      1. DMI expects the status code to 201 created , if it is other than that then it will result in exception (which will be handled by our exception handler and would result in 500 INTERNAL_SERVER_ERROR.

      Code from DmiServiceImpl (DMI plugin)  Existing

      final ResponseEntity<String> responseEntity = ncmpRestClient.registerCmHandlesWithNcmp(cmHandlesJson);
      if ((responseEntity.getStatusCode() != HttpStatus.CREATED)) {        throw new CmHandleRegistrationException(responseEntity.getBody()); }   So as per the high-level discussion we had we can check for *2XX* code (like below)  *Proposed change* \|final ResponseEntity<String> responseEntity = ncmpRestClient.registerCmHandlesWithNcmp(cmHandlesJson); if *((!responseEntity.getStatusCode().is2xxSuccessful()))* \{     throw new CmHandleRegistrationException(responseEntity.getBody()); }

       

            mpriyank Priyank Maheshwari
            mpriyank Priyank Maheshwari
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: