DefaultRefFilter: Avoid Repository#getAllRefs
Change-Id: I4817ffd75e7d3ec05ced085f10c0d4ef8f8816b2
This commit is contained in:
@@ -20,6 +20,7 @@ import static com.google.gerrit.reviewdb.client.RefNames.REFS_CHANGES;
|
||||
import static com.google.gerrit.reviewdb.client.RefNames.REFS_CONFIG;
|
||||
import static com.google.gerrit.reviewdb.client.RefNames.REFS_USERS_SELF;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
import static java.util.stream.Collectors.toMap;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Maps;
|
||||
@@ -248,7 +249,7 @@ class DefaultRefFilter {
|
||||
repo,
|
||||
opts.filterTagsSeparately()
|
||||
? filter(
|
||||
repo.getAllRefs(),
|
||||
getAllRefsMap(repo),
|
||||
repo,
|
||||
opts.toBuilder().setFilterTagsSeparately(false).build())
|
||||
.values()
|
||||
@@ -263,6 +264,14 @@ class DefaultRefFilter {
|
||||
return result;
|
||||
}
|
||||
|
||||
private static Map<String, Ref> getAllRefsMap(Repository repo) throws PermissionBackendException {
|
||||
try {
|
||||
return repo.getRefDatabase().getRefs().stream().collect(toMap(Ref::getName, r -> r));
|
||||
} catch (IOException e) {
|
||||
throw new PermissionBackendException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private Map<String, Ref> fastHideRefsMetaConfig(Map<String, Ref> refs)
|
||||
throws PermissionBackendException {
|
||||
if (refs.containsKey(REFS_CONFIG) && !canReadRef(REFS_CONFIG)) {
|
||||
|
||||
Reference in New Issue
Block a user