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:
@@ -52,7 +52,7 @@ final class DeleteAllocationTokensCommand extends UpdateOrDeleteAllocationTokens
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
tokensToDelete = getTokenKeys(tokens, prefix);
|
||||
tokensToDelete = tm().transact(() -> getTokenKeys(tokens, prefix));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user