Merge "Allow binding the module without GitRepositoryManager" into stable-3.3
diff --git a/src/main/java/com/googlesource/gerrit/plugins/cachedrefdb/CachedRefDatabase.java b/src/main/java/com/googlesource/gerrit/plugins/cachedrefdb/CachedRefDatabase.java
index 04541bd..e40e41b 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/cachedrefdb/CachedRefDatabase.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/cachedrefdb/CachedRefDatabase.java
@@ -140,7 +140,12 @@
 
   @Override
   public List<Ref> getRefs() throws IOException {
-    return delegate.getRefs();
+    List<Ref> allRefs = delegate.getRefs();
+    for (Ref ref : allRefs) {
+      refsCache.computeIfAbsent(
+          repo.getProjectName(), ref.getName(), () -> Optional.ofNullable(ref));
+    }
+    return allRefs;
   }
 
   @Override