lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nightowl...@apache.org
Subject [1/6] lucenenet git commit: BUG: Lucene.Net.TestFramework.Analysis.BaseTokenStreamTestCase: CountdownEvent was not being passed into the AnalysisThread. Also fixed the scenario to show the stack trace on the main thread rather than throw the exception on
Date Sun, 26 Mar 2017 08:43:18 GMT
Repository: lucenenet
Updated Branches:
  refs/heads/api-work 548e768cc -> d0d6c7e05


BUG: Lucene.Net.TestFramework.Analysis.BaseTokenStreamTestCase: CountdownEvent was not being
passed into the AnalysisThread. Also fixed the scenario to show the stack trace on the main
thread rather than throw the exception on another thread.


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

Branch: refs/heads/api-work
Commit: 6204e3257cfca4b60b4e7999dc63373f61cf31b7
Parents: e86433d
Author: Shad Storhaug <shad@shadstorhaug.com>
Authored: Sun Mar 26 15:21:48 2017 +0700
Committer: Shad Storhaug <shad@shadstorhaug.com>
Committed: Sun Mar 26 15:22:24 2017 +0700

----------------------------------------------------------------------
 .../Analysis/BaseTokenStreamTestCase.cs         | 29 +++++++++++++++-----
 1 file changed, 22 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/6204e325/src/Lucene.Net.TestFramework/Analysis/BaseTokenStreamTestCase.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.TestFramework/Analysis/BaseTokenStreamTestCase.cs b/src/Lucene.Net.TestFramework/Analysis/BaseTokenStreamTestCase.cs
index 502b322..dff6690 100644
--- a/src/Lucene.Net.TestFramework/Analysis/BaseTokenStreamTestCase.cs
+++ b/src/Lucene.Net.TestFramework/Analysis/BaseTokenStreamTestCase.cs
@@ -597,13 +597,14 @@ namespace Lucene.Net.Analysis
             // add memory barriers (ie alter how threads
             // interact)... so this is just "best effort":
             public bool Failed;
+            public Exception firstException = null;
 
             /// <summary>
             /// <param name="outerInstance">
             /// LUCENENET specific
             /// Added to remove a call to the then-static BaseTokenStreamTestCase methods</param>
             /// </summary>
-            internal AnalysisThread(long seed, /*CountdownEvent latch,*/ Analyzer a, int
iterations, int maxWordLength, 
+            internal AnalysisThread(long seed, CountdownEvent latch, Analyzer a, int iterations,
int maxWordLength, 
                 bool useCharFilter, bool simple, bool offsetsAreCorrect, RandomIndexWriter
iw, BaseTokenStreamTestCase outerInstance)
             {
                 this.Seed = seed;
@@ -614,7 +615,7 @@ namespace Lucene.Net.Analysis
                 this.Simple = simple;
                 this.OffsetsAreCorrect = offsetsAreCorrect;
                 this.Iw = iw;
-                this._latch = null;
+                this._latch = latch;
                 this.OuterInstance = outerInstance;
             }
 
@@ -631,8 +632,15 @@ namespace Lucene.Net.Analysis
                 }
                 catch (Exception e)
                 {
-                    Console.WriteLine("Exception in Thread: " + e);
-                    throw;
+                    //Console.WriteLine("Exception in Thread: " + e);
+                    //throw;
+                    // LUCENENET: Throwing an exception on another thread
+                    // is pointless, so we set it to a variable so we can read
+                    // it from our main thread (for debugging).
+                    if (firstException == null)
+                    {
+                        firstException = e;
+                    }
                 }
                 finally
                 {
@@ -674,7 +682,7 @@ namespace Lucene.Net.Analysis
                 var threads = new AnalysisThread[numThreads];
                 for (int i = 0; i < threads.Length; i++)
                 {
-                    threads[i] = new AnalysisThread(seed, /*startingGun,*/ a, iterations,
maxWordLength, useCharFilter, simple, offsetsAreCorrect, iw, this);
+                    threads[i] = new AnalysisThread(seed, startingGun, a, iterations, maxWordLength,
useCharFilter, simple, offsetsAreCorrect, iw, this);
                 }
                 
                 foreach (AnalysisThread thread in threads)
@@ -701,8 +709,15 @@ namespace Lucene.Net.Analysis
 #endif
                 }
 
-                if (threads.Any(x => x.Failed))
-                    Fail("Thread threw exception");
+                //if (threads.Any(x => x.Failed))
+                //    Fail("Thread threw exception");
+                foreach (var t in threads)
+                {
+                    if (t.Failed)
+                    {
+                        fail("Thread threw exception: " + t.firstException.ToString());
+                    }
+                }
 
                 success = true;
             }


Mime
View raw message