Skip to content

Commit e1c05c3

Browse files
Avoid ConcurrentModificationException for User class fields (opensearch-project#5087)
Signed-off-by: shikharj05 <8859327+shikharj05@users.noreply.github.com> 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>
1 parent 0326d7a commit e1c05c3

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/main/java/org/opensearch/security/securityconf/ConfigModelV7.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,10 @@ private Set<String> map(final User user, final TransportAddress caller) {
292292
return Collections.emptySet();
293293
}
294294

295-
final Set<String> securityRoles = new HashSet<>(user.getSecurityRoles());
295+
final Set<String> securityRoles = new HashSet<>();
296+
synchronized (user.getSecurityRoles()) {
297+
securityRoles.addAll(user.getSecurityRoles());
298+
}
296299

297300
if (rolesMappingResolution == ConfigConstants.RolesMappingResolution.BOTH
298301
|| rolesMappingResolution == ConfigConstants.RolesMappingResolution.BACKENDROLES_ONLY) {

0 commit comments

Comments
 (0)