Skip to content

Commit d4f6023

Browse files
committed
copy constructor
1 parent fc5dcd0 commit d4f6023

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/main/java/io/cryostat/recordings/RecordingMetadataManager.java

+11-4
Original file line numberDiff line numberDiff line change
@@ -1032,11 +1032,11 @@ public Metadata(Map<String, String> labels) {
10321032
}
10331033

10341034
void setSecurityContext(SecurityContext securityContext) {
1035-
this.securityContext = Objects.requireNonNull(securityContext);
1035+
this.securityContext = new SecurityContext(Objects.requireNonNull(securityContext));
10361036
}
10371037

10381038
public SecurityContext getSecurityContext() {
1039-
return securityContext;
1039+
return new SecurityContext(securityContext);
10401040
}
10411041

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

10581058
Metadata metadata = (Metadata) o;
1059-
return new EqualsBuilder().append(labels, metadata.labels).build();
1059+
return new EqualsBuilder()
1060+
.append(labels, metadata.labels)
1061+
.append(securityContext, metadata.securityContext)
1062+
.build();
10601063
}
10611064

10621065
@Override
10631066
public int hashCode() {
1064-
return new HashCodeBuilder().append(labels).toHashCode();
1067+
return new HashCodeBuilder().append(securityContext).append(labels).toHashCode();
10651068
}
10661069
}
10671070

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

1086+
SecurityContext(SecurityContext o) {
1087+
this.ctx = new HashMap<>(o.ctx);
1088+
}
1089+
10831090
public SecurityContext(ServiceRef serviceRef) {
10841091
this.ctx = new HashMap<>();
10851092
// FIXME this should be platform-specific

0 commit comments

Comments
 (0)