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:
committed by
David Pursehouse
parent
8b159eb1a1
commit
0f6f21c916
@@ -101,7 +101,7 @@ public class AccountCacheImpl implements AccountCache {
|
|||||||
return byId.get(accountId);
|
return byId.get(accountId);
|
||||||
} catch (ExecutionException e) {
|
} catch (ExecutionException e) {
|
||||||
logger.atWarning().withCause(e).log("Cannot load AccountState for ID %s", accountId);
|
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);
|
.orElseGet(Optional::empty);
|
||||||
} catch (IOException | ConfigInvalidException e) {
|
} catch (IOException | ConfigInvalidException e) {
|
||||||
logger.atWarning().withCause(e).log("Cannot load AccountState for username %s", username);
|
logger.atWarning().withCause(e).log("Cannot load AccountState for username %s", username);
|
||||||
return null;
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user