Skip to content

Commit

Permalink
Fix "not serializable" issues for correlation
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed Jan 16, 2024
1 parent 362f48b commit 08f9bed
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

import java.io.Serializable;
import java.util.*;
import java.util.stream.Collectors;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
Expand Down Expand Up @@ -196,8 +195,8 @@ public CorrelationPropertyValuesDescription(
@NotNull Set<PrismValue> secondaryValues,
@NotNull Match match) {
this.propertyDefinition = propertyDefinition;
this.primaryValues = primaryValues;
this.secondaryValues = secondaryValues;
this.primaryValues = Set.copyOf(primaryValues); // to be serializable
this.secondaryValues = Set.copyOf(secondaryValues); // to be serializable
this.match = match;
}

Expand All @@ -223,9 +222,16 @@ public String toString() {

private List<String> dump(Collection<PrismValue> values) {
return values.stream()
.map(PrismValue::getRealValue)
.map(prismValue -> {
try {
return prismValue.getRealValue();
} catch (Exception e) {
// getRealValue may throw an exception in rare cases (for containers, maybe)
return prismValue.toString();
}
})
.map(String::valueOf)
.collect(Collectors.toList());
.toList();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public ChildCorrelationExplanationRecord(
this.explanation = explanation;
this.weight = weight;
this.confidenceIncrement = confidenceIncrement;
this.ignoredBecause = ignoredBecause;
this.ignoredBecause = Set.copyOf(ignoredBecause); // to be serializable
}

@Override
Expand Down

0 comments on commit 08f9bed

Please sign in to comment.