Skip to content

Commit

Permalink
Fix unique key violation exception when concurrent group patch reques…
Browse files Browse the repository at this point in the history
…ts trying to add same users to the group
  • Loading branch information
shashimalcse committed May 28, 2024
1 parent 0fa6a00 commit c367c57
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3535,6 +3535,13 @@ private void doPatchGroup(String groupId, String currentGroupName, Map<String, L
// Update the group name in UM_HYBRID_GROUP_ROLE table.
carbonUM.updateGroupName(currentGroupName, newGroupName);
} catch (UserStoreException e) {
if (e instanceof org.wso2.carbon.user.core.UserStoreException && StringUtils
.equals(UserCoreErrorConstants.ErrorMessages.ERROR_CODE_DUPLICATE_WHILE_WRITING_TO_DATABASE.getCode(),
((org.wso2.carbon.user.core.UserStoreException) e).getErrorCode())) {
// This handles the scenario where a unique key violation exception occurs when concurrent group
// patch requests try to add the same users to the group.
return;
}
if (e instanceof org.wso2.carbon.user.core.UserStoreException && StringUtils
.equals(UserCoreErrorConstants.ErrorMessages.ERROR_CODE_NON_EXISTING_USER.getCode(),
((org.wso2.carbon.user.core.UserStoreException) e).getErrorCode())) {
Expand Down

0 comments on commit c367c57

Please sign in to comment.