This is an automated email from the ASF dual-hosted git repository.

nightowl888 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/lucenenet.git

commit 889a4349218a5d789875a3fe9515a8ff199b36d7
Author: Shad Storhaug <[email protected]>
AuthorDate: Tue Mar 16 21:54:49 2021 +0700

    Lucene.Net.Facet.Taxonomy.Directory.DirectoryTaxonomyReader: Restored locks 
on SetCacheSize() method.
---
 .../Taxonomy/Directory/DirectoryTaxonomyReader.cs  | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/src/Lucene.Net.Facet/Taxonomy/Directory/DirectoryTaxonomyReader.cs 
b/src/Lucene.Net.Facet/Taxonomy/Directory/DirectoryTaxonomyReader.cs
index 1106db8..91f6a81 100644
--- a/src/Lucene.Net.Facet/Taxonomy/Directory/DirectoryTaxonomyReader.cs
+++ b/src/Lucene.Net.Facet/Taxonomy/Directory/DirectoryTaxonomyReader.cs
@@ -422,10 +422,24 @@ namespace Lucene.Net.Facet.Taxonomy.Directory
         public virtual void SetCacheSize(int size)
         {
             EnsureOpen();
-            // LUCENENET specific - removed locking here because these 
collections
-            // internally use Interlocked.Exchange
-            categoryCache.Limit = size;
-            ordinalCache.Limit = size;
+            categoryCacheLock.EnterWriteLock();
+            try
+            {
+                categoryCache.Limit = size;
+            }
+            finally
+            {
+                categoryCacheLock.ExitWriteLock();
+            }
+            ordinalCacheLock.EnterWriteLock();
+            try
+            {
+                ordinalCache.Limit = size;
+            }
+            finally
+            {
+                ordinalCacheLock.ExitWriteLock();
+            }
         }
 
         /// <summary>

Reply via email to