]> source.dussan.org Git - jgit.git/commitdiff
Fix RefDirectory not closing resources 02/55902/5
authorHugo Arès <hugo.ares@ericsson.com>
Tue, 8 Sep 2015 13:21:31 +0000 (09:21 -0400)
committerMatthias Sohn <matthias.sohn@sap.com>
Thu, 7 Apr 2016 09:32:57 +0000 (11:32 +0200)
When repositories are opened using the RepositoryCache, they are kept in
memory and when the repository usage counter reaches 0, the
Repository.close method is called which then calls close method on its
reference and object databases.

The problem is that RefDirectory.close method was a no-op and the
reference database was kept in memory. This problem is only happening
when opening a repository using the RepositoryCache because it never
evicts repositories, it's just calling the close method.

Change-Id: Iacb961de8e8b1f5b37824bf0d1a4caf4c6f1233f
Signed-off-by: Hugo Arès <hugo.ares@ericsson.com>
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectory.java

index b8c2fb4a51975614068ea5c20d58f33c1a796eba..6f3166a680f584f95d37093f01214975731e6edb 100644 (file)
@@ -203,10 +203,10 @@ public class RefDirectory extends RefDatabase {
 
        @Override
        public void close() {
-               // We have no resources to close.
+               clearReferences();
        }
 
-       void rescan() {
+       private void clearReferences() {
                looseRefs.set(RefList.<LooseRef> emptyList());
                packedRefs.set(PackedRefList.NO_PACKED_REFS);
        }
@@ -214,7 +214,7 @@ public class RefDirectory extends RefDatabase {
        @Override
        public void refresh() {
                super.refresh();
-               rescan();
+               clearReferences();
        }
 
        @Override