Skip to content

Commit

Permalink
Avoid ConcurrentModificationException for User class fields (opensear…
Browse files Browse the repository at this point in the history
…ch-project#5087)

Signed-off-by: shikharj05 <[email protected]>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
1 parent 0326d7a commit e1c05c3
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,10 @@ private Set<String> map(final User user, final TransportAddress caller) {
return Collections.emptySet();
}

final Set<String> securityRoles = new HashSet<>(user.getSecurityRoles());
final Set<String> securityRoles = new HashSet<>();
synchronized (user.getSecurityRoles()) {
securityRoles.addAll(user.getSecurityRoles());
}

if (rolesMappingResolution == ConfigConstants.RolesMappingResolution.BOTH
|| rolesMappingResolution == ConfigConstants.RolesMappingResolution.BACKENDROLES_ONLY) {
Expand Down

0 comments on commit e1c05c3

Please sign in to comment.