Skip to content

Commit

Permalink
Fix the null pointer for operation json list.
Browse files Browse the repository at this point in the history
  • Loading branch information
Malith-19 committed Jul 1, 2024
1 parent 5e0de7a commit 43a6538
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -753,6 +753,18 @@ public ArrayList<PatchOperation> decodeRequest(String scimResourceString) throws
JSONObject decodedJsonObj = new JSONObject(new JSONTokener(scimResourceString));
//obtain the Operations values
JSONArray operationJsonList = (JSONArray) decodedJsonObj.opt(SCIMConstants.OperationalConstants.OPERATIONS);

//check if operationJsonList is null
if (operationJsonList == null) {

//check if operations field present in lowercase
if (decodedJsonObj.has(StringUtils.lowerCase(SCIMConstants.OperationalConstants.OPERATIONS))) {
throw new BadRequestException("Invalid JSON schema.", ResponseCodeConstants.INVALID_SYNTAX);
}

throw new BadRequestException(ResponseCodeConstants.INVALID_SYNTAX);
}

//for each operation, create a PatchOperation object and add the relevant values to it
for (int count = 0; count < operationJsonList.length(); count++) {
JSONObject operation = (JSONObject) operationJsonList.get(count);
Expand Down

0 comments on commit 43a6538

Please sign in to comment.