Skip to content

Commit 693467a

Browse files
authored
Remove duplicate transaction in updateAllocTokens (#2637)
1 parent cea3da0 commit 693467a

File tree

2 files changed

+7
-12
lines changed

2 files changed

+7
-12
lines changed

core/src/main/java/google/registry/tools/DeleteAllocationTokensCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ final class DeleteAllocationTokensCommand extends UpdateOrDeleteAllocationTokens
5252

5353
@Override
5454
public void init() {
55-
tokensToDelete = getTokenKeys(tokens, prefix);
55+
tokensToDelete = tm().transact(() -> getTokenKeys(tokens, prefix));
5656
}
5757

5858
@Override

core/src/main/java/google/registry/tools/UpdateOrDeleteAllocationTokensCommand.java

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,21 +59,16 @@ public static ImmutableList<VKey<AllocationToken>> getTokenKeys(
5959
.map(token -> VKey.create(AllocationToken.class, token))
6060
.collect(toImmutableList());
6161
ImmutableList<VKey<AllocationToken>> nonexistentKeys =
62-
tm().transact(
63-
() -> keys.stream().filter(key -> !tm().exists(key)).collect(toImmutableList()));
62+
keys.stream().filter(key -> !tm().exists(key)).collect(toImmutableList());
6463
checkState(nonexistentKeys.isEmpty(), "Tokens with keys %s did not exist", nonexistentKeys);
6564
return keys;
6665
} else {
6766
checkArgument(!prefix.isEmpty(), "Provided prefix should not be blank");
68-
return tm().transact(
69-
() ->
70-
tm().query(
71-
"SELECT token FROM AllocationToken WHERE token LIKE :prefix",
72-
String.class)
73-
.setParameter("prefix", String.format("%s%%", prefix))
74-
.getResultStream()
75-
.map(token -> VKey.create(AllocationToken.class, token))
76-
.collect(toImmutableList()));
67+
return tm().query("SELECT token FROM AllocationToken WHERE token LIKE :prefix", String.class)
68+
.setParameter("prefix", String.format("%s%%", prefix))
69+
.getResultStream()
70+
.map(token -> VKey.create(AllocationToken.class, token))
71+
.collect(toImmutableList());
7772
}
7873
}
7974
}

0 commit comments

Comments
 (0)