Don't index missing accounts

AccountCache#get returns an empty AccountState instance for missing
accounts. Rather use AccountCache#getOrNull and don't index missing
accounts.

Change-Id: I6984e3c9cfc452fb8991031e1a5283a6792b4d96
Signed-off-by: Edwin Kempin <ekempin@google.com>
This commit is contained in:
Edwin Kempin 2017-06-06 17:21:50 +02:00
parent ef360d8541
commit fbcd038e53

View File

@ -64,8 +64,13 @@ public class AccountIndexerImpl implements AccountIndexer {
@Override
public void index(Account.Id id) throws IOException {
for (Index<?, AccountState> i : getWriteIndexes()) {
i.replace(byIdCache.get(id));
for (Index<Account.Id, AccountState> i : getWriteIndexes()) {
AccountState accountState = byIdCache.getOrNull(id);
if (accountState != null) {
i.replace(accountState);
} else {
i.delete(id);
}
}
fireAccountIndexedEvent(id.get());
}