Skip to content

Commit

Permalink
Fixed early exit on special case [] == null
Browse files Browse the repository at this point in the history
Signed-off-by: Tony Tkacik <tonydamage@gmail.com>
  • Loading branch information
tonydamage committed May 12, 2021
1 parent 317a3fc commit 05ab5b0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Expand Up @@ -594,7 +594,7 @@ boolean diffInternal(Item<V, D> other, Collection<? extends ItemDelta> deltas, b
ItemDelta delta = createDelta();
if (other == null) {
// Early exit for equals use case
if (exitOnDiff) {
if (exitOnDiff && hasAnyValue()) {
return true;
}

Expand Down
Expand Up @@ -47,6 +47,7 @@ public class PrismContainerValueImpl<C extends Containerable> extends PrismValue


public static final RuntimeException DIFFERENT_ITEMS_EXCEPTION = new ItemDifferentException();
private static final boolean EARLY_EXIT = true;

static {
DIFFERENT_ITEMS_EXCEPTION.fillInStackTrace();
Expand Down Expand Up @@ -1131,11 +1132,16 @@ private boolean diffItems(PrismContainerValue<C> thisValue, PrismContainerValue<
}
}

// Other has an item that we don't have, this must be an add
// Other item has no values
if(otherItem.hasNoValues()) {
continue;
}
if (exitOnDiff) {
return true;
}

ItemDelta itemDelta = otherItem.createDelta();

itemDelta.addValuesToAdd(otherItem.getClonedValues());
if (!itemDelta.isEmpty()) {
((Collection) deltas).add(itemDelta);
Expand Down Expand Up @@ -1446,7 +1452,7 @@ private boolean equals(@NotNull PrismContainerValue<?> other, ParameterizedEquiv
private boolean equalsItems(PrismContainerValue<C> other, ParameterizedEquivalenceStrategy strategy) {
Collection<? extends ItemDelta<?, ?>> deltas = FailOnAddList.INSTANCE;
try {
boolean different = diffItems(this, other, deltas, strategy, true);
boolean different = diffItems(this, other, deltas, strategy, EARLY_EXIT);
if (different) {
return false;
}
Expand Down

0 comments on commit 05ab5b0

Please sign in to comment.