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 7f2b76a0a81c3fbe7dd5e329cbf1d6504dba9e2c
Author: Shad Storhaug <[email protected]>
AuthorDate: Tue Jul 9 22:17:03 2019 +0700

    BUG: Fixed invalid method call introduced in #222 to ClearLock that caused 
the path to double up, which caused the GetCanonicalPathOfLockFile method to 
fail.
---
 src/Lucene.Net.Tests/Store/TestLockFactory.cs |  2 +-
 src/Lucene.Net/Store/NativeFSLockFactory.cs   | 11 ++++++-----
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/src/Lucene.Net.Tests/Store/TestLockFactory.cs 
b/src/Lucene.Net.Tests/Store/TestLockFactory.cs
index 9fcaa65..2ab4d78 100644
--- a/src/Lucene.Net.Tests/Store/TestLockFactory.cs
+++ b/src/Lucene.Net.Tests/Store/TestLockFactory.cs
@@ -199,7 +199,7 @@ namespace Lucene.Net.Store
         }
 
         // Verify: NativeFSLockFactory works correctly
-        [Test, LongRunningTest]
+        [Test]
         public virtual void TestNativeFSLockFactory()
         {
             var f = new 
NativeFSLockFactory(CreateTempDir("testNativeFsLockFactory"));
diff --git a/src/Lucene.Net/Store/NativeFSLockFactory.cs 
b/src/Lucene.Net/Store/NativeFSLockFactory.cs
index a99e178..e21d345 100644
--- a/src/Lucene.Net/Store/NativeFSLockFactory.cs
+++ b/src/Lucene.Net/Store/NativeFSLockFactory.cs
@@ -90,8 +90,8 @@ namespace Lucene.Net.Store
 
                // LUCENENET: NativeFSLocks in Java are infact singletons; this 
is how we mimick that to track instances and make sure
                // IW.Unlock and IW.IsLocked works correctly
-        private static readonly Dictionary<string, Lock> locks = new 
Dictionary<string, Lock>();
-        private static readonly object locksSyncLock = new object();
+        internal static readonly Dictionary<string, Lock> locks = new 
Dictionary<string, Lock>();
+        internal static readonly object syncLock = new object();
 
                /// <summary>
                /// Given a lock name, return the full prefixed path of the 
actual lock file.
@@ -111,7 +111,7 @@ namespace Lucene.Net.Store
         {
             var path = GetCanonicalPathOfLockFile(lockName);
             Lock l;
-                       lock (locksSyncLock)
+                       lock (syncLock)
                        {
                                if (!locks.TryGetValue(path, out l))
                                        locks.Add(path, l = NewLock(path));
@@ -135,7 +135,7 @@ namespace Lucene.Net.Store
             Lock l;
                        // this is the reason why we can't use 
ConcurrentDictionary: we need the removal and disposal of the lock to be atomic
                        // otherwise it may clash with MakeLock making a lock 
and ClearLock disposing of it in another thread.
-                       lock (locksSyncLock)
+                       lock (syncLock)
                        {
                                if (locks.TryGetValue(path, out l))
                                {
@@ -474,7 +474,8 @@ namespace Lucene.Net.Store
                     // the lock instance from the dictionary that tracks them.
                     try
                     {
-                                               outerInstance?.ClearLock(path);
+                        lock (NativeFSLockFactory.syncLock)
+                            NativeFSLockFactory.locks.Remove(path);
                     }
                     finally
                     {

Reply via email to