Skip to content

Commit

Permalink
copy constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewazores committed Nov 2, 2022
1 parent 400f27d commit a3033a4
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/main/java/io/cryostat/recordings/RecordingMetadataManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -1032,11 +1032,11 @@ public Metadata(Map<String, String> labels) {
}

void setSecurityContext(SecurityContext securityContext) {
this.securityContext = Objects.requireNonNull(securityContext);
this.securityContext = new SecurityContext(Objects.requireNonNull(securityContext));
}

public SecurityContext getSecurityContext() {
return securityContext;
return new SecurityContext(securityContext);
}

public Map<String, String> getLabels() {
Expand All @@ -1056,12 +1056,15 @@ public boolean equals(Object o) {
}

Metadata metadata = (Metadata) o;
return new EqualsBuilder().append(labels, metadata.labels).build();
return new EqualsBuilder()
.append(labels, metadata.labels)
.append(securityContext, metadata.securityContext)
.build();
}

@Override
public int hashCode() {
return new HashCodeBuilder().append(labels).toHashCode();
return new HashCodeBuilder().append(securityContext).append(labels).toHashCode();
}
}

Expand All @@ -1080,6 +1083,10 @@ private SecurityContext(Map<String, String> ctx) {
this.ctx = Collections.unmodifiableMap(new HashMap<>(ctx));
}

SecurityContext(SecurityContext o) {
this.ctx = new HashMap<>(o.ctx);
}

public SecurityContext(ServiceRef serviceRef) {
this.ctx = new HashMap<>();
// FIXME this should be platform-specific
Expand Down

0 comments on commit a3033a4

Please sign in to comment.