Make LockHandlerImpl.clock transient

SystemClock isn't Serializable (for obvious reasons), whereas LockHandlerImpl is
used as a field on some Serializable mapreduce classes. So mark it transient and
then re-generate it on first use following de-serialization when it happens to
be null.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=201707209
This commit is contained in:
mcilwain 2018-06-22 10:43:21 -07:00 committed by Ben McIlwain
parent 0422205d84
commit 8245d2f1c4
3 changed files with 25 additions and 14 deletions

View file

@ -23,6 +23,7 @@ import static org.mockito.Mockito.verify;
import google.registry.model.server.Lock;
import google.registry.testing.AppEngineRule;
import google.registry.testing.FakeClock;
import google.registry.util.RequestStatusCheckerImpl;
import java.util.Optional;
import java.util.concurrent.Callable;
import java.util.concurrent.TimeoutException;
@ -72,7 +73,7 @@ public final class LockHandlerImplTest {
}
private boolean executeWithLocks(Callable<Void> callable, final @Nullable Lock acquiredLock) {
LockHandlerImpl lockHandler = new LockHandlerImpl() {
LockHandlerImpl lockHandler = new LockHandlerImpl(new RequestStatusCheckerImpl(), clock) {
private static final long serialVersionUID = 0L;
@Override
Optional<Lock> acquire(String resourceName, String tld, Duration leaseLength) {
@ -82,7 +83,6 @@ public final class LockHandlerImplTest {
return Optional.ofNullable(acquiredLock);
}
};
lockHandler.clock = clock;
return lockHandler.executeWithLocks(callable, "tld", ONE_DAY, "resourceName");
}