lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From synhers...@apache.org
Subject [12/46] lucenenet git commit: Fixed cache cleanup bug in Facet.Taxonomy.WriterCache.NameIntCacheLRU.
Date Tue, 04 Oct 2016 20:01:42 GMT
Fixed cache cleanup bug in Facet.Taxonomy.WriterCache.NameIntCacheLRU.


Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/c40662a2
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/c40662a2
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/c40662a2

Branch: refs/heads/master
Commit: c40662a239a4debbbbfd3e1756386e10b302f499
Parents: de9e8ce
Author: Shad Storhaug <shad@shadstorhaug.com>
Authored: Sat Sep 24 23:53:20 2016 +0700
Committer: Shad Storhaug <shad@shadstorhaug.com>
Committed: Mon Oct 3 23:30:58 2016 +0700

----------------------------------------------------------------------
 .../Taxonomy/WriterCache/NameIntCacheLRU.cs            | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c40662a2/src/Lucene.Net.Facet/Taxonomy/WriterCache/NameIntCacheLRU.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Facet/Taxonomy/WriterCache/NameIntCacheLRU.cs b/src/Lucene.Net.Facet/Taxonomy/WriterCache/NameIntCacheLRU.cs
index ce14f49..a761aea 100644
--- a/src/Lucene.Net.Facet/Taxonomy/WriterCache/NameIntCacheLRU.cs
+++ b/src/Lucene.Net.Facet/Taxonomy/WriterCache/NameIntCacheLRU.cs
@@ -1,4 +1,5 @@
 ´╗┐using System.Collections.Generic;
+using System.Linq;
 
 namespace Lucene.Net.Facet.Taxonomy.WriterCache
 {
@@ -152,13 +153,13 @@ namespace Lucene.Net.Facet.Taxonomy.WriterCache
             {
                 return false;
             }
-            IEnumerator<object> it = cache.Keys.GetEnumerator();
-            int i = 0;
-            
-            while (i < n && it.MoveNext())
+
+            // LUCENENET: Loop in reverse so we can safely delete
+            // a range of items (0 - n) without a 
+            // "Collection was modified" conflict
+            for (int i = n - 1; i >= 0; i--)
             {
-                cache.Remove(it.Current);
-                i++;
+                cache.Remove(cache.Keys.ElementAt(i));
             }
             return true;
         }


Mime
View raw message