StarredChangesUtil: Fix NPE when ref to be deleted doesn't exist
When deleting star refs on a change deletion the star refs are computed from the index which may be stale. If the ref that we want to delete doesn't exist that's fine and we can just skip it. This NPE was observed when a change deletion failed with LOCK_FAILURE and then the request was automatically retried. Signed-off-by: Edwin Kempin <ekempin@google.com> Change-Id: Icb73fdfd5bf6141176b733a25809c59e7f4d5c22
This commit is contained in:
@@ -254,7 +254,9 @@ public class StarredChangesUtil {
|
||||
for (Account.Id accountId : byChangeFromIndex(changeId).keySet()) {
|
||||
String refName = RefNames.refsStarredChanges(changeId, accountId);
|
||||
Ref ref = repo.getRefDatabase().exactRef(refName);
|
||||
batchUpdate.addCommand(new ReceiveCommand(ref.getObjectId(), ObjectId.zeroId(), refName));
|
||||
if (ref != null) {
|
||||
batchUpdate.addCommand(new ReceiveCommand(ref.getObjectId(), ObjectId.zeroId(), refName));
|
||||
}
|
||||
}
|
||||
batchUpdate.execute(rw, NullProgressMonitor.INSTANCE);
|
||||
for (ReceiveCommand command : batchUpdate.getCommands()) {
|
||||
|
||||
Reference in New Issue
Block a user