Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Signed-off-by: Stephen Crawford <[email protected]>
  • Loading branch information
stephen-crawford committed Nov 16, 2023
1 parent b0799c1 commit 79afd83
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/main/java/org/opensearch/security/user/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,18 @@ public class User implements Serializable, Writeable, CustomAttributesAware {
/**
* roles == backend_roles
*/
private final Set<String> roles = new HashSet<String>();
private final Set<String> openDistroSecurityRoles = new HashSet<String>();
private final Set<String> roles = Collections.synchronizedSet(new HashSet<String>());
private final Set<String> openDistroSecurityRoles = Collections.synchronizedSet(new HashSet<String>());
private String requestedTenant;
private Map<String, String> attributes = new HashMap<>();
private Map<String, String> attributes = Collections.synchronizedMap(new HashMap<>());
private boolean isInjected = false;

public User(final StreamInput in) throws IOException {
super();
name = in.readString();
roles.addAll(in.readList(StreamInput::readString));
requestedTenant = in.readString();
attributes = in.readMap(StreamInput::readString, StreamInput::readString);
attributes = attributes = Collections.synchronizedMap(in.readMap(StreamInput::readString, StreamInput::readString));
openDistroSecurityRoles.addAll(in.readList(StreamInput::readString));
}

Expand Down Expand Up @@ -254,7 +254,7 @@ public void writeTo(StreamOutput out) throws IOException {
*/
public synchronized final Map<String, String> getCustomAttributesMap() {
if(attributes == null) {
attributes = new HashMap<>();
attributes = Collections.synchronizedMap(new HashMap<>());
}
return attributes;
}
Expand All @@ -266,6 +266,6 @@ public final void addSecurityRoles(final Collection<String> securityRoles) {
}

public final Set<String> getSecurityRoles() {
return this.openDistroSecurityRoles == null ? Collections.emptySet() : Collections.unmodifiableSet(this.openDistroSecurityRoles);
return this.openDistroSecurityRoles == null ? Collections.synchronizedSet(Collections.emptySet()) : Collections.unmodifiableSet(this.openDistroSecurityRoles);
}
}

0 comments on commit 79afd83

Please sign in to comment.