Skip to content

Commit

Permalink
Stop narrowing deltas when raw
Browse files Browse the repository at this point in the history
If the delta or the base item is raw, the "narrow" method does not
work adequately (because of pitfalls related to comparison of raw
values). Perhaps the simplest and most effective solution is to
disable narrowing the delta if either the delta or the base item
itself has some raw parts.

This resolves MID-7918 (the part related to ignoring modifications
of "const" based configuration properties).
  • Loading branch information
mederly committed Apr 29, 2024
1 parent dfd35ea commit 3a1f23d
Showing 1 changed file with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -879,6 +879,9 @@ public ItemDelta<V, D> narrow(@NotNull PrismObject<? extends Objectable> object,
return narrowWhenNoItem(object, assumeMissingItems);
} else if (currentItem.isIncomplete() && currentItem.hasNoValues() && assumeMissingItems) {
return this;
} else if (currentItem.hasRaw() || hasAnyRawValue()) {
// Raw comparisons are imprecise. To avoid losing any modifications, we keep the delta untouched in this case.
return this;
} else {
if (isReplace()) {
return narrowReplaceDelta(currentItem, plusComparator);
Expand Down Expand Up @@ -1854,6 +1857,24 @@ private Boolean isRawSet(Collection<V> set) {
return true;
}

public boolean hasAnyRawValue() {
return hasAnyRawValue(valuesToAdd)
|| hasAnyRawValue(valuesToReplace)
|| hasAnyRawValue(valuesToDelete);
}

private boolean hasAnyRawValue(Collection<V> set) {
if (set == null) {
return false;
}
for (V val : set) {
if (val.isRaw()) {
return true;
}
}
return false;
}

@Override
public void revive(PrismContext prismContext) throws SchemaException {
reviveSet(valuesToAdd, prismContext);
Expand Down

0 comments on commit 3a1f23d

Please sign in to comment.