Fix the shell to allow multiple mutation of the same entity

Because of the objectify cache, after the first "read, change, write" of the
first mutation - the second mutation would "read" the original value, which
would then fail to be written with the error "Entity changed since init()".

This was specifically seen in the "UpdateRegistrarCommand", but likely affected
other commands as well.

Clearing the cache before each command solves this issue.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=192328213
This commit is contained in:
guyben 2018-04-10 12:34:18 -07:00 committed by Ben McIlwain
parent e0c32337fd
commit 3dfd141e0f

View file

@ -18,6 +18,7 @@ import com.google.appengine.tools.remoteapi.RemoteApiInstaller;
import com.google.appengine.tools.remoteapi.RemoteApiOptions;
import static com.google.common.base.Preconditions.checkState;
import static google.registry.model.ofy.ObjectifyService.ofy;
import static google.registry.tools.Injector.injectReflectively;
import com.beust.jcommander.JCommander;
@ -203,6 +204,9 @@ final class RegistryCli implements AutoCloseable, CommandRunner {
// Ensure that all entity classes are loaded before command code runs.
ObjectifyService.initOfy();
// Make sure we start the command with a clean cache, so that any previous command won't
// interfere with this one.
ofy().clearSessionCache();
command.run();
}