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).

(cherry picked from commit 7c193d3)
  • Loading branch information
mederly committed Apr 29, 2024
1 parent 4ccda01 commit 061dbf2
Showing 1 changed file with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -874,6 +874,9 @@ public ItemDelta<V, D> narrow(@NotNull PrismObject<? extends Objectable> object,
Item<V, D> currentItem = object.findItem(getPath());
if (currentItem == null) {
return narrowWhenNoItem(object, assumeMissingItems);
} 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 @@ -1860,6 +1863,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 061dbf2

Please sign in to comment.