From 5f5cb8df9ff7230c0b99a99633db8770c3fd8c72 Mon Sep 17 00:00:00 2001 From: Ben McIlwain Date: Mon, 24 Jul 2023 13:37:36 -0400 Subject: [PATCH] Remove unnecessary overload of AsyncTaskEnqueuer.enqueueAsyncResave() (#2083) It was only called in one place (in actual production code), and it was just slightly obscuring the fact that re-saves can be scheduled for multiple points in the future in a way that wasn't amazingly helpful to understanding of the system logic at the callsite. --- .../main/java/google/registry/batch/AsyncTaskEnqueuer.java | 6 ------ .../registry/flows/domain/DomainTransferRequestFlow.java | 4 +++- .../java/google/registry/batch/AsyncTaskEnqueuerTest.java | 4 ++-- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/core/src/main/java/google/registry/batch/AsyncTaskEnqueuer.java b/core/src/main/java/google/registry/batch/AsyncTaskEnqueuer.java index ec393ad9e..555fdb8ff 100644 --- a/core/src/main/java/google/registry/batch/AsyncTaskEnqueuer.java +++ b/core/src/main/java/google/registry/batch/AsyncTaskEnqueuer.java @@ -50,12 +50,6 @@ public final class AsyncTaskEnqueuer { this.cloudTasksUtils = cloudTasksUtils; } - /** Enqueues a task to asynchronously re-save an entity at some point in the future. */ - public void enqueueAsyncResave( - VKey entityToResave, DateTime now, DateTime whenToResave) { - enqueueAsyncResave(entityToResave, now, ImmutableSortedSet.of(whenToResave)); - } - /** * Enqueues a task to asynchronously re-save an entity at some point(s) in the future. * diff --git a/core/src/main/java/google/registry/flows/domain/DomainTransferRequestFlow.java b/core/src/main/java/google/registry/flows/domain/DomainTransferRequestFlow.java index 63a2de4f3..c250fd06d 100644 --- a/core/src/main/java/google/registry/flows/domain/DomainTransferRequestFlow.java +++ b/core/src/main/java/google/registry/flows/domain/DomainTransferRequestFlow.java @@ -38,6 +38,7 @@ import static google.registry.persistence.transaction.TransactionManagerFactory. import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; +import com.google.common.collect.ImmutableSortedSet; import google.registry.batch.AsyncTaskEnqueuer; import google.registry.flows.EppException; import google.registry.flows.ExtensionManager; @@ -286,7 +287,8 @@ public final class DomainTransferRequestFlow implements TransactionalFlow { .build(); DomainHistory domainHistory = buildDomainHistory(newDomain, tld, now, period); - asyncTaskEnqueuer.enqueueAsyncResave(newDomain.createVKey(), now, automaticTransferTime); + asyncTaskEnqueuer.enqueueAsyncResave( + newDomain.createVKey(), now, ImmutableSortedSet.of(automaticTransferTime)); tm().putAll( new ImmutableSet.Builder<>() .add(newDomain, domainHistory, requestPollMessage) diff --git a/core/src/test/java/google/registry/batch/AsyncTaskEnqueuerTest.java b/core/src/test/java/google/registry/batch/AsyncTaskEnqueuerTest.java index d75a16319..60f9a9cd3 100644 --- a/core/src/test/java/google/registry/batch/AsyncTaskEnqueuerTest.java +++ b/core/src/test/java/google/registry/batch/AsyncTaskEnqueuerTest.java @@ -69,7 +69,7 @@ public class AsyncTaskEnqueuerTest { void test_enqueueAsyncResave_success() { Contact contact = persistActiveContact("jd23456"); asyncTaskEnqueuer.enqueueAsyncResave( - contact.createVKey(), clock.nowUtc(), clock.nowUtc().plusDays(5)); + contact.createVKey(), clock.nowUtc(), ImmutableSortedSet.of(clock.nowUtc().plusDays(5))); cloudTasksHelper.assertTasksEnqueued( QUEUE_ASYNC_ACTIONS, new CloudTasksHelper.TaskMatcher() @@ -108,7 +108,7 @@ public class AsyncTaskEnqueuerTest { void test_enqueueAsyncResave_ignoresTasksTooFarIntoFuture() { Contact contact = persistActiveContact("jd23456"); asyncTaskEnqueuer.enqueueAsyncResave( - contact.createVKey(), clock.nowUtc(), clock.nowUtc().plusDays(31)); + contact.createVKey(), clock.nowUtc(), ImmutableSortedSet.of(clock.nowUtc().plusDays(31))); cloudTasksHelper.assertNoTasksEnqueued(QUEUE_ASYNC_ACTIONS); assertLogMessage(logHandler, Level.INFO, "Ignoring async re-save"); }