From bc8a9a2258ec8ce86f9a78f8253218212ea127e6 Mon Sep 17 00:00:00 2001 From: JeethJJ Date: Thu, 16 May 2024 15:48:54 +0530 Subject: [PATCH] AssociatedRolesConfig null check is only required when getting list of roles --- .../application/UpdateAssociatedRoles.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/core/functions/application/UpdateAssociatedRoles.java b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/core/functions/application/UpdateAssociatedRoles.java index 5312559465..2c98826768 100644 --- a/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/core/functions/application/UpdateAssociatedRoles.java +++ b/components/org.wso2.carbon.identity.api.server.application.management/org.wso2.carbon.identity.api.server.application.management.v1/src/main/java/org/wso2/carbon/identity/api/server/application/management/v1/core/functions/application/UpdateAssociatedRoles.java @@ -36,13 +36,15 @@ public void apply(ServiceProvider serviceProvider, AssociatedRolesConfig associa org.wso2.carbon.identity.application.common.model.AssociatedRolesConfig rolesConfig = new org.wso2.carbon.identity.application.common.model.AssociatedRolesConfig(); - if (associatedRolesConfig != null && associatedRolesConfig.getRoles() != null) { + if (associatedRolesConfig != null) { rolesConfig.setAllowedAudience(associatedRolesConfig.getAllowedAudience().toString()); - List listOfRoles = - associatedRolesConfig.getRoles().stream() - .map(role -> new org.wso2.carbon.identity.application.common.model.RoleV2(role.getId())) - .collect(Collectors.toList()); - rolesConfig.setRoles(listOfRoles.toArray(new RoleV2[0])); + if (associatedRolesConfig.getRoles() != null) { + List listOfRoles = + associatedRolesConfig.getRoles().stream() + .map(role -> new org.wso2.carbon.identity.application.common.model.RoleV2(role.getId())) + .collect(Collectors.toList()); + rolesConfig.setRoles(listOfRoles.toArray(new RoleV2[0])); + } } serviceProvider.setAssociatedRolesConfig(rolesConfig); }