ChangeJson: Project control cache is dead; remove it
ChangeJson tries to use Cache<Project.NameKey, ProjectControl> to
optimize construction of ChangeControl in control() method:
if (cd.hasChangeControl()) {
ctrl = cd.changeControl().forUser(userProvider.get());
} else {
ctrl = projectControls.get(cd.change().getProject())
.controlFor(cd.change());
}
However during rendering of multiple changes as result of change query
execution, the condition:
if (cd.hasChangeControl()) {
ctrl = cd.changeControl().forUser(userProvider.get());
}
is always true and the cache is never used. That's because is_visible()
predicate is always get added to the query passed by user in:
public List<List<ChangeData>> queryChanges(List<String> queries) {
final Predicate<ChangeData> visibleToMe = queryBuilder.is_visible();
[...]
Predicate<ChangeData> q = parseQuery(query, visibleToMe);
Predicate<ChangeData> s = queryRewriter.rewrite(q, start);
And the is_visible() predicate creates ChangeControl and set it into
ChangeData instance by calling cacheVisibleTo() method:
void cacheVisibleTo(ChangeControl ctl) {
visibleTo = ctl.getCurrentUser();
changeControl = ctl;
}
Change-Id: I596c1be8f5fcd6060797a9d601d00c982689b6bd
1 file changed