summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuca Milanesio <luca.milanesio@gmail.com>2021-10-01 22:50:42 +0100
committerLuca Milanesio <luca.milanesio@gmail.com>2021-10-06 21:16:40 +0000
commit7b131cdbafdb80fd3dc68c6f3aa12a9d711cc9e3 (patch)
treefc94ac0776a965cb18ec9924d24e9e90aac15954
parenta331568d38ed469566c810ead6785247ae9e6ec9 (diff)
Reuse the already opened Repository for refs filtering
Gerrit needs to access the Change status for refs filtering for hiding the private ones. Reuse the Repository already opened for the fetching of all changes avoiding the open/close of the same one for every single change. Change-Id: I8796d17e4d3876835392b4132f22d1821b2840d7
-rw-r--r--java/com/google/gerrit/server/permissions/DefaultRefFilter.java7
1 files changed, 4 insertions, 3 deletions
diff --git a/java/com/google/gerrit/server/permissions/DefaultRefFilter.java b/java/com/google/gerrit/server/permissions/DefaultRefFilter.java
index eca30b60c8..03d3b63c74 100644
--- a/java/com/google/gerrit/server/permissions/DefaultRefFilter.java
+++ b/java/com/google/gerrit/server/permissions/DefaultRefFilter.java
@@ -142,7 +142,7 @@ class DefaultRefFilter {
return ImmutableList.of();
}
if (RefNames.isRefsChanges(refName)) {
- boolean isChangeRefVisisble = canSeeSingleChangeRef(refName);
+ boolean isChangeRefVisisble = canSeeSingleChangeRef(repo, refName);
if (isChangeRefVisisble) {
logger.atFinest().log("Change ref %s is visible", refName);
return refs;
@@ -466,7 +466,8 @@ class DefaultRefFilter {
* with refs-in-wants is used as that enables Gerrit to skip traditional advertisement of all
* visible refs.
*/
- private boolean canSeeSingleChangeRef(String refName) throws PermissionBackendException {
+ private boolean canSeeSingleChangeRef(Repository repo, String refName)
+ throws PermissionBackendException {
// We are treating just a single change ref. We are therefore not going through regular ref
// filtering, but use NoteDb directly. This makes it so that we can always serve this ref
// even if the change is not part of the set of most recent changes that
@@ -480,7 +481,7 @@ class DefaultRefFilter {
}
ChangeNotes notes;
try {
- notes = changeNotesFactory.create(projectState.getNameKey(), cId);
+ notes = changeNotesFactory.create(repo, projectState.getNameKey(), cId);
} catch (StorageException e) {
throw new PermissionBackendException("can't construct change notes", e);
}