mirror of
https://github.com/google/nomulus
synced 2025-12-23 14:25:44 +00:00
Remove duplicate transaction in updateAllocTokens (#2637)
This commit is contained in:
@@ -52,7 +52,7 @@ final class DeleteAllocationTokensCommand extends UpdateOrDeleteAllocationTokens
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init() {
|
public void init() {
|
||||||
tokensToDelete = getTokenKeys(tokens, prefix);
|
tokensToDelete = tm().transact(() -> getTokenKeys(tokens, prefix));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -59,21 +59,16 @@ abstract class UpdateOrDeleteAllocationTokensCommand extends ConfirmingCommand {
|
|||||||
.map(token -> VKey.create(AllocationToken.class, token))
|
.map(token -> VKey.create(AllocationToken.class, token))
|
||||||
.collect(toImmutableList());
|
.collect(toImmutableList());
|
||||||
ImmutableList<VKey<AllocationToken>> nonexistentKeys =
|
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);
|
checkState(nonexistentKeys.isEmpty(), "Tokens with keys %s did not exist", nonexistentKeys);
|
||||||
return keys;
|
return keys;
|
||||||
} else {
|
} else {
|
||||||
checkArgument(!prefix.isEmpty(), "Provided prefix should not be blank");
|
checkArgument(!prefix.isEmpty(), "Provided prefix should not be blank");
|
||||||
return tm().transact(
|
return tm().query("SELECT token FROM AllocationToken WHERE token LIKE :prefix", String.class)
|
||||||
() ->
|
.setParameter("prefix", String.format("%s%%", prefix))
|
||||||
tm().query(
|
.getResultStream()
|
||||||
"SELECT token FROM AllocationToken WHERE token LIKE :prefix",
|
.map(token -> VKey.create(AllocationToken.class, token))
|
||||||
String.class)
|
.collect(toImmutableList());
|
||||||
.setParameter("prefix", String.format("%s%%", prefix))
|
|
||||||
.getResultStream()
|
|
||||||
.map(token -> VKey.create(AllocationToken.class, token))
|
|
||||||
.collect(toImmutableList()));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user