Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 26610200B8B for ; Tue, 4 Oct 2016 22:01:34 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 25139160AF2; Tue, 4 Oct 2016 20:01:34 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 382D3160AF3 for ; Tue, 4 Oct 2016 22:01:33 +0200 (CEST) Received: (qmail 21112 invoked by uid 500); 4 Oct 2016 20:01:32 -0000 Mailing-List: contact commits-help@lucenenet.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: lucene-net-dev@lucenenet.apache.org Delivered-To: mailing list commits@lucenenet.apache.org Received: (qmail 20835 invoked by uid 99); 4 Oct 2016 20:01:32 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 04 Oct 2016 20:01:32 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id CA15CE7DE8; Tue, 4 Oct 2016 20:01:31 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: synhershko@apache.org To: commits@lucenenet.apache.org Date: Tue, 04 Oct 2016 20:01:42 -0000 Message-Id: In-Reply-To: <24a353907def438ca7013b548e833d9e@git.apache.org> References: <24a353907def438ca7013b548e833d9e@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [12/46] lucenenet git commit: Fixed cache cleanup bug in Facet.Taxonomy.WriterCache.NameIntCacheLRU. archived-at: Tue, 04 Oct 2016 20:01:34 -0000 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 Authored: Sat Sep 24 23:53:20 2016 +0700 Committer: Shad Storhaug 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 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; }