AccountCacheImpl: Don't return null on error but Optional.empty()

Callers do not expect that methods that return an Optional may also
return null.

Signed-off-by: Edwin Kempin <ekempin@google.com>
Change-Id: I1962891693aaa9048771f5f7eae7c303a826da13
This commit is contained in:
Edwin Kempin
2019-07-16 11:39:15 +02:00
committed by David Pursehouse
parent 8b159eb1a1
commit 0f6f21c916

View File

@@ -101,7 +101,7 @@ public class AccountCacheImpl implements AccountCache {
return byId.get(accountId);
} catch (ExecutionException e) {
logger.atWarning().withCause(e).log("Cannot load AccountState for ID %s", accountId);
return null;
return Optional.empty();
}
}
@@ -149,7 +149,7 @@ public class AccountCacheImpl implements AccountCache {
.orElseGet(Optional::empty);
} catch (IOException | ConfigInvalidException e) {
logger.atWarning().withCause(e).log("Cannot load AccountState for username %s", username);
return null;
return Optional.empty();
}
}