ChangeData: Expect that Account.Id.fromRefPart may return null

In practice this should never happen since before calling
Account.Id.fromRefPart we verified that it's a change edit ref. Hence
this is not a bug-fix but rather improving readability.

We cannot annotate Account.Id.fromRefPart with @Nullable since the
Account class is used in the GWT UI where @Nullable is not available.
However the follow-up change modifies this method to return an Optional.

Change-Id: Iae9d34e4ee225decd6ab4367827c1505d18acbdb
Signed-off-by: Edwin Kempin <ekempin@google.com>
This commit is contained in:
Edwin Kempin
2018-02-02 12:00:59 +01:00
parent 827c755b75
commit a7c80b0003

View File

@@ -1011,7 +1011,10 @@ public class ChangeData {
for (Map.Entry<String, Ref> e :
repo.getRefDatabase().getRefs(RefNames.REFS_USERS).entrySet()) {
if (id.equals(Change.Id.fromEditRefPart(e.getKey()))) {
editsByUser.put(Account.Id.fromRefPart(e.getKey()), e.getValue());
Account.Id accountId = Account.Id.fromRefPart(e.getKey());
if (accountId != null) {
editsByUser.put(accountId, e.getValue());
}
}
}
} catch (IOException e) {