Merge "Catch NoSuchChangeExceptions in ChangeFinder"

This commit is contained in:
Patrick Hiesel
2017-08-29 15:00:03 +00:00
committed by Gerrit Code Review
2 changed files with 16 additions and 10 deletions

View File

@@ -181,7 +181,7 @@ public class ChangeFinder {
List<ChangeControl> ctls = new ArrayList<>(cds.size());
if (!indexConfig.separateChangeSubIndexes()) {
for (ChangeData cd : cds) {
ctls.add(cd.changeControl(user));
checkedAdd(cd, ctls, user);
}
return ctls;
}
@@ -195,9 +195,18 @@ public class ChangeFinder {
Set<Change.Id> seen = Sets.newHashSetWithExpectedSize(cds.size());
for (ChangeData cd : cds) {
if (seen.add(cd.getId())) {
ctls.add(cd.changeControl(user));
checkedAdd(cd, ctls, user);
}
}
return ctls;
}
private static void checkedAdd(ChangeData cd, List<ChangeControl> ctls, CurrentUser user)
throws OrmException {
try {
ctls.add(cd.changeControl(user));
} catch (NoSuchChangeException e) {
// Ignore
}
}
}

View File

@@ -615,14 +615,11 @@ public class ChangeData {
}
throw new IllegalStateException("user already specified: " + changeControl.getUser());
}
try {
if (change != null) {
changeControl = changeControlFactory.controlFor(db, change, user);
} else {
changeControl = changeControlFactory.controlFor(db, project(), legacyId, user);
}
} catch (NoSuchChangeException e) {
throw new OrmException(e);
if (change != null) {
changeControl = changeControlFactory.controlFor(db, change, user);
} else {
changeControl = changeControlFactory.controlFor(db, project(), legacyId, user);
}
return changeControl;
}