diff --git a/core/src/main/java/google/registry/backup/ReplayCommitLogsToSqlAction.java b/core/src/main/java/google/registry/backup/ReplayCommitLogsToSqlAction.java index 389acffef..7b786abd7 100644 --- a/core/src/main/java/google/registry/backup/ReplayCommitLogsToSqlAction.java +++ b/core/src/main/java/google/registry/backup/ReplayCommitLogsToSqlAction.java @@ -85,7 +85,7 @@ public class ReplayCommitLogsToSqlAction implements Runnable { Optional lock = Lock.acquire( this.getClass().getSimpleName(), null, LEASE_LENGTH, requestStatusChecker, false); - if (lock.isEmpty()) { + if (!lock.isPresent()) { String message = "Can't acquire SQL commit log replay lock, aborting."; logger.atSevere().log(message); // App Engine will retry on any non-2xx status code, which we don't want in this case. @@ -182,7 +182,7 @@ public class ReplayCommitLogsToSqlAction implements Runnable { } private static int compareByWeight(VersionedEntity a, VersionedEntity b) { - return getEntityPriority(a.key().getKind(), a.getEntity().isEmpty()) - - getEntityPriority(b.key().getKind(), b.getEntity().isEmpty()); + return getEntityPriority(a.key().getKind(), !a.getEntity().isPresent()) + - getEntityPriority(b.key().getKind(), !b.getEntity().isPresent()); } } diff --git a/core/src/main/java/google/registry/flows/domain/token/AllocationTokenFlowUtils.java b/core/src/main/java/google/registry/flows/domain/token/AllocationTokenFlowUtils.java index 5093c30e3..cb7c75448 100644 --- a/core/src/main/java/google/registry/flows/domain/token/AllocationTokenFlowUtils.java +++ b/core/src/main/java/google/registry/flows/domain/token/AllocationTokenFlowUtils.java @@ -154,7 +154,7 @@ public class AllocationTokenFlowUtils { } Optional maybeTokenEntity = tm().loadByKeyIfPresent(VKey.create(AllocationToken.class, token)); - if (maybeTokenEntity.isEmpty()) { + if (!maybeTokenEntity.isPresent()) { throw new InvalidAllocationTokenException(); } if (maybeTokenEntity.get().isRedeemed()) { diff --git a/core/src/main/java/google/registry/tools/DeleteAllocationTokensCommand.java b/core/src/main/java/google/registry/tools/DeleteAllocationTokensCommand.java index 337cc8fe9..8dd6472f7 100644 --- a/core/src/main/java/google/registry/tools/DeleteAllocationTokensCommand.java +++ b/core/src/main/java/google/registry/tools/DeleteAllocationTokensCommand.java @@ -76,7 +76,7 @@ final class DeleteAllocationTokensCommand extends UpdateOrDeleteAllocationTokens // since the query ran. This also filters out per-domain tokens if they're not to be deleted. ImmutableSet> tokensToDelete = tm().loadByKeys(batch).values().stream() - .filter(t -> withDomains || t.getDomainName().isEmpty()) + .filter(t -> withDomains || !t.getDomainName().isPresent()) .filter(t -> SINGLE_USE.equals(t.getTokenType())) .filter(t -> !t.isRedeemed()) .map(AllocationToken::createVKey) diff --git a/core/src/main/java/google/registry/tools/GetAllocationTokenCommand.java b/core/src/main/java/google/registry/tools/GetAllocationTokenCommand.java index 6fe9ee16b..5697ffb5f 100644 --- a/core/src/main/java/google/registry/tools/GetAllocationTokenCommand.java +++ b/core/src/main/java/google/registry/tools/GetAllocationTokenCommand.java @@ -59,7 +59,7 @@ final class GetAllocationTokenCommand implements CommandWithRemoteApi { if (loadedTokens.containsKey(token)) { AllocationToken loadedToken = loadedTokens.get(token); System.out.println(loadedToken.toString()); - if (loadedToken.getRedemptionHistoryEntry().isEmpty()) { + if (!loadedToken.getRedemptionHistoryEntry().isPresent()) { System.out.printf("Token %s was not redeemed.\n", token); } else { Key domainOfyKey =