Remove unnecessary LocalDiskRepositoryManager refresh The GitRepositoryManager implementation should be responsible for its own internal caches (if any). Here LocalDiskRepositoryManager already knows it created a new repository and has already updated its cached list information, before firing the event the plugin is listening on. Plugins should try to avoid referencing LocalDiskRepositoryManager directly, so that they can load on servers that use other types of GitRepositoryManager implementations. Change-Id: I200449e082bea7f4ac79330fd07c56031ed1c9f5
diff --git a/src/main/java/com/googlesource/gerrit/plugins/branchnetwork/data/GitCommitCacheRefresh.java b/src/main/java/com/googlesource/gerrit/plugins/branchnetwork/data/GitCommitCacheRefresh.java index 9840bb2..851cbcb 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/branchnetwork/data/GitCommitCacheRefresh.java +++ b/src/main/java/com/googlesource/gerrit/plugins/branchnetwork/data/GitCommitCacheRefresh.java
@@ -18,7 +18,6 @@ import com.google.common.cache.LoadingCache; import com.google.gerrit.extensions.events.GitReferenceUpdatedListener; import com.google.gerrit.extensions.events.NewProjectCreatedListener; -import com.google.gerrit.server.git.LocalDiskRepositoryManager; import com.google.inject.Inject; import com.google.inject.name.Named; import com.googlesource.gerrit.plugins.branchnetwork.data.json.Commit; @@ -26,12 +25,11 @@ public class GitCommitCacheRefresh implements GitReferenceUpdatedListener, NewProjectCreatedListener { private LoadingCache<String, List<Commit>> networkGraphDataCache; - private final LocalDiskRepositoryManager repoManager; @Inject public GitCommitCacheRefresh( - @Named(GitCommitCache.GRAPH_DATA_CACHE) final LoadingCache<String, List<Commit>> networkGraphDataCache, - final LocalDiskRepositoryManager repoManager) { + @Named(GitCommitCache.GRAPH_DATA_CACHE) final LoadingCache<String, + List<Commit>> networkGraphDataCache) { this.networkGraphDataCache = networkGraphDataCache; this.repoManager = repoManager; } @@ -40,8 +38,6 @@ public void onNewProjectCreated( com.google.gerrit.extensions.events.NewProjectCreatedListener.Event event) { networkGraphDataCache.refresh(event.getProjectName()); - repoManager.list(); // Invoked for flushing the LocalDiskRepositoryManager project list cache - } @Override