lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From synhers...@apache.org
Subject [03/21] git commit: Fixed TestDoubleBarrelLRUCache.TestThreadCorrectness
Date Fri, 19 Sep 2014 14:19:36 GMT
Fixed TestDoubleBarrelLRUCache.TestThreadCorrectness

Faulty equals() had led to runtime an type error. Time comparison with
current time was incorrectly C#ized.


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

Branch: refs/heads/master
Commit: 9b9b4a264dc0e02f9c2bc57891bbd652029ba5c5
Parents: 95cd6c2
Author: Prad Nelluru <prnell@microsoft.com>
Authored: Tue Sep 16 12:01:20 2014 -0700
Committer: Prad Nelluru <prnell@microsoft.com>
Committed: Tue Sep 16 12:01:20 2014 -0700

----------------------------------------------------------------------
 .../core/Util/TestDoubleBarrelLRUCache.cs              | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/9b9b4a26/src/Lucene.Net.Tests/core/Util/TestDoubleBarrelLRUCache.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Util/TestDoubleBarrelLRUCache.cs b/src/Lucene.Net.Tests/core/Util/TestDoubleBarrelLRUCache.cs
index 6c87358..5b3f7bb 100644
--- a/src/Lucene.Net.Tests/core/Util/TestDoubleBarrelLRUCache.cs
+++ b/src/Lucene.Net.Tests/core/Util/TestDoubleBarrelLRUCache.cs
@@ -79,10 +79,10 @@ namespace Lucene.Net.Util
 
             internal readonly CloneableObject[] Objs;
             internal readonly DoubleBarrelLRUCache<CloneableObject, object> c;
-            internal readonly long EndTime;
+            internal readonly DateTime EndTime;
             internal volatile bool Failed;
 
-            public CacheThread(TestDoubleBarrelLRUCache outerInstance, DoubleBarrelLRUCache<CloneableObject,
object> c, CloneableObject[] objs, long endTime)
+            public CacheThread(TestDoubleBarrelLRUCache outerInstance, DoubleBarrelLRUCache<CloneableObject,
object> c, CloneableObject[] objs, DateTime endTime)
             {
                 this.OuterInstance = outerInstance;
                 this.c = c;
@@ -115,7 +115,7 @@ namespace Lucene.Net.Util
                         }
                         if ((++count % 10000) == 0)
                         {
-                            if (DateTime.Now.Millisecond >= EndTime)
+                            if (DateTime.Now.CompareTo(EndTime) > 0)
                             {
                                 break;
                             }
@@ -156,7 +156,7 @@ namespace Lucene.Net.Util
             }
 
             CacheThread[] threads = new CacheThread[NUM_THREADS];
-            long endTime = DateTime.Now.Millisecond + 1000L;
+            DateTime endTime = DateTime.Now.AddSeconds(1);
             for (int i = 0; i < NUM_THREADS; i++)
             {
                 threads[i] = new CacheThread(this, c, objs, endTime);
@@ -181,7 +181,10 @@ namespace Lucene.Net.Util
 
             public override bool Equals(object other)
             {
-                return this.Value.Equals(((CloneableObject)other).Value);
+                if (other.GetType().Equals(typeof (CloneableObject)))
+                    return this.Value.Equals(((CloneableObject) other).Value);
+                else
+                    return false;
             }
 
             public override int GetHashCode()


Mime
View raw message