From 3dc4cd8e4fca0cfd561f6dae33dc86ad7bca713c Mon Sep 17 00:00:00 2001 From: Rachel Guan Date: Tue, 11 May 2021 15:24:35 -0400 Subject: [PATCH] Create key based on the change type (#1147) * Create key based on the change type --- .../java/google/registry/tools/MutatingCommand.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/core/src/main/java/google/registry/tools/MutatingCommand.java b/core/src/main/java/google/registry/tools/MutatingCommand.java index 3eba52689..62150d703 100644 --- a/core/src/main/java/google/registry/tools/MutatingCommand.java +++ b/core/src/main/java/google/registry/tools/MutatingCommand.java @@ -105,20 +105,20 @@ public abstract class MutatingCommand extends ConfirmingCommand implements Comma */ private EntityChange(ImmutableObject oldEntity, ImmutableObject newEntity, VKey vkey) { type = ChangeType.get(oldEntity != null, newEntity != null); - Key oldKey = Key.create(oldEntity), newKey = Key.create(newEntity); if (type == ChangeType.UPDATE) { checkArgument( - oldKey.equals(newKey), "Both entity versions in an update must have the same Key."); + Key.create(oldEntity).equals(Key.create(newEntity)), + "Both entity versions in an update must have the same Key."); checkArgument( - oldKey.equals(vkey.getOfyKey()), + Key.create(oldEntity).equals(vkey.getOfyKey()), "The Key of the entity must be the same as the OfyKey of the vkey"); } else if (type == ChangeType.CREATE) { checkArgument( - newKey.equals(vkey.getOfyKey()), + Key.create(newEntity).equals(vkey.getOfyKey()), "Both entity versions in an update must have the same Key."); } else if (type == ChangeType.DELETE) { checkArgument( - oldKey.equals(vkey.getOfyKey()), + Key.create(oldEntity).equals(vkey.getOfyKey()), "The Key of the entity must be the same as the OfyKey of the vkey"); } this.oldEntity = oldEntity;