From 693467a165d6b6968ac0945a6a13c711417948cf Mon Sep 17 00:00:00 2001 From: gbrodman Date: Mon, 13 Jan 2025 14:12:06 -0500 Subject: [PATCH] Remove duplicate transaction in updateAllocTokens (#2637) --- .../tools/DeleteAllocationTokensCommand.java | 2 +- .../UpdateOrDeleteAllocationTokensCommand.java | 17 ++++++----------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/core/src/main/java/google/registry/tools/DeleteAllocationTokensCommand.java b/core/src/main/java/google/registry/tools/DeleteAllocationTokensCommand.java index 03e13bee6..da329b4a7 100644 --- a/core/src/main/java/google/registry/tools/DeleteAllocationTokensCommand.java +++ b/core/src/main/java/google/registry/tools/DeleteAllocationTokensCommand.java @@ -52,7 +52,7 @@ final class DeleteAllocationTokensCommand extends UpdateOrDeleteAllocationTokens @Override public void init() { - tokensToDelete = getTokenKeys(tokens, prefix); + tokensToDelete = tm().transact(() -> getTokenKeys(tokens, prefix)); } @Override diff --git a/core/src/main/java/google/registry/tools/UpdateOrDeleteAllocationTokensCommand.java b/core/src/main/java/google/registry/tools/UpdateOrDeleteAllocationTokensCommand.java index 322a38a11..f67113f28 100644 --- a/core/src/main/java/google/registry/tools/UpdateOrDeleteAllocationTokensCommand.java +++ b/core/src/main/java/google/registry/tools/UpdateOrDeleteAllocationTokensCommand.java @@ -59,21 +59,16 @@ abstract class UpdateOrDeleteAllocationTokensCommand extends ConfirmingCommand { .map(token -> VKey.create(AllocationToken.class, token)) .collect(toImmutableList()); ImmutableList> nonexistentKeys = - tm().transact( - () -> keys.stream().filter(key -> !tm().exists(key)).collect(toImmutableList())); + keys.stream().filter(key -> !tm().exists(key)).collect(toImmutableList()); checkState(nonexistentKeys.isEmpty(), "Tokens with keys %s did not exist", nonexistentKeys); return keys; } else { checkArgument(!prefix.isEmpty(), "Provided prefix should not be blank"); - return tm().transact( - () -> - tm().query( - "SELECT token FROM AllocationToken WHERE token LIKE :prefix", - String.class) - .setParameter("prefix", String.format("%s%%", prefix)) - .getResultStream() - .map(token -> VKey.create(AllocationToken.class, token)) - .collect(toImmutableList())); + return tm().query("SELECT token FROM AllocationToken WHERE token LIKE :prefix", String.class) + .setParameter("prefix", String.format("%s%%", prefix)) + .getResultStream() + .map(token -> VKey.create(AllocationToken.class, token)) + .collect(toImmutableList()); } } }