1
0
mirror of https://github.com/google/nomulus synced 2025-12-23 06:15:42 +00:00

Remove duplicate transaction in updateAllocTokens (#2637)

This commit is contained in:
gbrodman
2025-01-13 14:12:06 -05:00
committed by GitHub
parent cea3da01a0
commit 693467a165
2 changed files with 7 additions and 12 deletions

View File

@@ -52,7 +52,7 @@ final class DeleteAllocationTokensCommand extends UpdateOrDeleteAllocationTokens
@Override
public void init() {
tokensToDelete = getTokenKeys(tokens, prefix);
tokensToDelete = tm().transact(() -> getTokenKeys(tokens, prefix));
}
@Override

View File

@@ -59,21 +59,16 @@ abstract class UpdateOrDeleteAllocationTokensCommand extends ConfirmingCommand {
.map(token -> VKey.create(AllocationToken.class, token))
.collect(toImmutableList());
ImmutableList<VKey<AllocationToken>> 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());
}
}
}