Skip to content

Commit

Permalink
Fix "immutable primary delta" fix (MID-6097)
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed Mar 5, 2020
1 parent eb894e6 commit d4a9ada
Showing 1 changed file with 4 additions and 4 deletions.
Expand Up @@ -259,7 +259,7 @@ public void addPrimaryDelta(ObjectDelta<O> delta) throws SchemaException {
}

public void swallowToPrimaryDelta(ItemDelta<?,?> itemDelta) throws SchemaException {
createOrModifyPrimaryDelta(
modifyOrCreatePrimaryDelta(
delta -> delta.swallow(itemDelta),
() -> {
ObjectDelta<O> newPrimaryDelta = getPrismContext().deltaFactory().object().create(getObjectTypeClass(), ChangeType.MODIFY);
Expand All @@ -279,15 +279,15 @@ private interface DeltaCreator<O extends Objectable> {
ObjectDelta<O> create() throws SchemaException;
}

private void createOrModifyPrimaryDelta(DeltaModifier<O> modifier, DeltaCreator<O> creator) throws SchemaException {
private void modifyOrCreatePrimaryDelta(DeltaModifier<O> modifier, DeltaCreator<O> creator) throws SchemaException {
if (primaryDelta == null) {
primaryDelta = creator.create();
} else if (!primaryDelta.isImmutable()) {
modifier.modify(primaryDelta);
} else {
primaryDelta = primaryDelta.clone();
primaryDelta.setImmutable(false);
modifier.modify(primaryDelta);
primaryDelta.freeze();
primaryDelta.setImmutable(true);
}
}

Expand Down

0 comments on commit d4a9ada

Please sign in to comment.