lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From synhers...@apache.org
Subject [17/32] lucenenet git commit: Fixing non-static calls from private classes using OuterInstance
Date Fri, 12 Aug 2016 13:25:30 GMT
Fixing non-static calls from private classes using OuterInstance


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

Branch: refs/heads/master
Commit: 95bd05b76fbde14a852e789dc4c445dc93cb7d6e
Parents: 659d952
Author: Connie Yau <conniey@microsoft.com>
Authored: Sun Jul 31 22:50:16 2016 -0700
Committer: Connie Yau <conniey@microsoft.com>
Committed: Sun Jul 31 22:50:16 2016 -0700

----------------------------------------------------------------------
 .../ThreadedIndexingAndSearchingTestCase.cs     |  2 +-
 .../core/Index/TestBagOfPostings.cs             |  2 +-
 .../core/Index/TestIndexWriter.cs               | 28 ++++++++++----------
 .../core/Index/TestIndexWriterDelete.cs         |  6 ++---
 .../core/Index/TestIndexWriterExceptions.cs     | 24 ++++++++---------
 .../core/Index/TestIndexWriterWithThreads.cs    | 26 +++++++++++-------
 .../core/Index/TestIndexableField.cs            |  2 +-
 .../core/Index/TestNeverDelete.cs               | 10 +++++--
 .../core/Index/TestRollingUpdates.cs            |  7 +++--
 .../core/Index/TestSnapshotDeletionPolicy.cs    |  8 +++---
 .../core/Index/TestStressIndexing.cs            | 15 ++++++-----
 .../core/Index/TestStressIndexing2.cs           | 10 +++----
 .../core/Index/TestStressNRT.cs                 | 12 ++++-----
 .../core/Index/TestThreadedForceMerge.cs        |  4 +--
 .../core/Index/TestTransactions.cs              |  4 +--
 .../core/Store/TestRAMDirectory.cs              |  2 +-
 16 files changed, 91 insertions(+), 71 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/95bd05b7/src/Lucene.Net.TestFramework/Index/ThreadedIndexingAndSearchingTestCase.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.TestFramework/Index/ThreadedIndexingAndSearchingTestCase.cs b/src/Lucene.Net.TestFramework/Index/ThreadedIndexingAndSearchingTestCase.cs
index 72e6994..74d15c0 100644
--- a/src/Lucene.Net.TestFramework/Index/ThreadedIndexingAndSearchingTestCase.cs
+++ b/src/Lucene.Net.TestFramework/Index/ThreadedIndexingAndSearchingTestCase.cs
@@ -801,7 +801,7 @@ namespace Lucene.Net.Index
                     }
                 }
 
-                IndexSearcher searcher = NewSearcher(reader);
+                IndexSearcher searcher = OuterInstance.NewSearcher(reader);
                 sum += searcher.Search(new TermQuery(new Term("body", "united")), 10).TotalHits;
 
                 if (VERBOSE)

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/95bd05b7/src/Lucene.Net.Tests/core/Index/TestBagOfPostings.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Index/TestBagOfPostings.cs b/src/Lucene.Net.Tests/core/Index/TestBagOfPostings.cs
index 1650604..6f4741e 100644
--- a/src/Lucene.Net.Tests/core/Index/TestBagOfPostings.cs
+++ b/src/Lucene.Net.Tests/core/Index/TestBagOfPostings.cs
@@ -151,7 +151,7 @@ namespace Lucene.Net.Index
                 try
                 {
                     Document document = new Document();
-                    Field field = NewTextField("field", "", Field.Store.NO);
+                    Field field = OuterInstance.NewTextField("field", "", Field.Store.NO);
                     document.Add(field);
                     StartingGun.Wait();
                     while (!(Postings.Count == 0))

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/95bd05b7/src/Lucene.Net.Tests/core/Index/TestIndexWriter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Index/TestIndexWriter.cs b/src/Lucene.Net.Tests/core/Index/TestIndexWriter.cs
index d1fe9dd..b1c9888 100644
--- a/src/Lucene.Net.Tests/core/Index/TestIndexWriter.cs
+++ b/src/Lucene.Net.Tests/core/Index/TestIndexWriter.cs
@@ -145,14 +145,14 @@ namespace Lucene.Net.Index
             dir.Dispose();
         }
 
-        internal static void AddDoc(IndexWriter writer)
+        private void AddDoc(IndexWriter writer)
         {
             Document doc = new Document();
             doc.Add(NewTextField("content", "aaa", Field.Store.NO));
             writer.AddDocument(doc);
         }
 
-        internal static void AddDocWithIndex(IndexWriter writer, int index)
+        private void AddDocWithIndex(IndexWriter writer, int index)
         {
             Document doc = new Document();
             doc.Add(NewField("content", "aaa " + index, StoredTextType));
@@ -1137,11 +1137,11 @@ namespace Lucene.Net.Index
                 // make a little directory for addIndexes
                 // LUCENE-2239: won't work with NIOFS/MMAP
                 Adder = new MockDirectoryWrapper(this.Random, new RAMDirectory());
-                IndexWriterConfig conf = NewIndexWriterConfig(this.Random, TEST_VERSION_CURRENT,
new MockAnalyzer(this.Random));
+                IndexWriterConfig conf = OuterInstance.NewIndexWriterConfig(this.Random,
TEST_VERSION_CURRENT, new MockAnalyzer(this.Random));
                 IndexWriter w = new IndexWriter(Adder, conf);
                 Document doc = new Document();
-                doc.Add(NewStringField(this.Random, "id", "500", Field.Store.NO));
-                doc.Add(NewField(this.Random, "field", "some prepackaged text contents",
StoredTextType));
+                doc.Add(OuterInstance.NewStringField(this.Random, "id", "500", Field.Store.NO));
+                doc.Add(OuterInstance.NewField(this.Random, "field", "some prepackaged text
contents", StoredTextType));
                 if (DefaultCodecSupportsDocValues())
                 {
                     doc.Add(new BinaryDocValuesField("binarydv", new BytesRef("500")));
@@ -1155,8 +1155,8 @@ namespace Lucene.Net.Index
                 }
                 w.AddDocument(doc);
                 doc = new Document();
-                doc.Add(NewStringField(this.Random, "id", "501", Field.Store.NO));
-                doc.Add(NewField(this.Random, "field", "some more contents", StoredTextType));
+                doc.Add(OuterInstance.NewStringField(this.Random, "id", "501", Field.Store.NO));
+                doc.Add(OuterInstance.NewField(this.Random, "field", "some more contents",
StoredTextType));
                 if (DefaultCodecSupportsDocValues())
                 {
                     doc.Add(new BinaryDocValuesField("binarydv", new BytesRef("501")));
@@ -1199,17 +1199,17 @@ namespace Lucene.Net.Index
                                 w.Dispose();
                                 w = null;
                             }
-                            IndexWriterConfig conf = NewIndexWriterConfig(Random, TEST_VERSION_CURRENT,
new MockAnalyzer(Random)).SetMaxBufferedDocs(2);
+                            IndexWriterConfig conf = OuterInstance.NewIndexWriterConfig(Random,
TEST_VERSION_CURRENT, new MockAnalyzer(Random)).SetMaxBufferedDocs(2);
                             w = new IndexWriter(dir, conf);
 
                             Document doc = new Document();
-                            Field idField = NewStringField(Random, "id", "", Field.Store.NO);
+                            Field idField = OuterInstance.NewStringField(Random, "id", "",
Field.Store.NO);
                             Field binaryDVField = null;
                             Field numericDVField = null;
                             Field sortedDVField = null;
                             Field sortedSetDVField = new SortedSetDocValuesField("sortedsetdv",
new BytesRef());
                             doc.Add(idField);
-                            doc.Add(NewField(Random, "field", "some text contents", StoredTextType));
+                            doc.Add(OuterInstance.NewField(Random, "field", "some text contents",
StoredTextType));
                             if (DefaultCodecSupportsDocValues())
                             {
                                 binaryDVField = new BinaryDocValuesField("binarydv", new
BytesRef());
@@ -1933,7 +1933,7 @@ namespace Lucene.Net.Index
         public virtual void TestWickedLongTerm()
         {
             Directory dir = NewDirectory();
-            RandomIndexWriter w = new RandomIndexWriter(Random(), dir, new StringSplitAnalyzer());
+            RandomIndexWriter w = new RandomIndexWriter(Random(), dir, new StringSplitAnalyzer(),
Similarity, TimeZone);
 
             char[] chars = new char[DocumentsWriterPerThread.MAX_TERM_LENGTH_UTF8];
             Arrays.Fill(chars, 'x');
@@ -1986,7 +1986,7 @@ namespace Lucene.Net.Index
             Field contentField = new Field("content", "", customType);
             doc.Add(contentField);
 
-            w = new RandomIndexWriter(Random(), dir, ClassEnvRule.Similarity, ClassEnvRule.TimeZone);
+            w = new RandomIndexWriter(Random(), dir, Similarity, TimeZone);
 
             contentField.StringValue = "other";
             w.AddDocument(doc);
@@ -2090,7 +2090,7 @@ namespace Lucene.Net.Index
             // somehow "knows" a lock is held against write.lock
             // even if you remove that file:
             d.LockFactory = new SimpleFSLockFactory();
-            RandomIndexWriter w1 = new RandomIndexWriter(Random(), d);
+            RandomIndexWriter w1 = new RandomIndexWriter(Random(), d, Similarity, TimeZone);
             w1.DeleteAll();
             try
             {
@@ -2854,7 +2854,7 @@ namespace Lucene.Net.Index
                 dir.DeleteFile(fileName);
             }
 
-            w = new RandomIndexWriter(Random(), dir, ClassEnvRule.Similarity, ClassEnvRule.TimeZone);
+            w = new RandomIndexWriter(Random(), dir, Similarity, TimeZone);
             w.AddDocument(doc);
             w.Dispose();
             r.Dispose();

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/95bd05b7/src/Lucene.Net.Tests/core/Index/TestIndexWriterDelete.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Index/TestIndexWriterDelete.cs b/src/Lucene.Net.Tests/core/Index/TestIndexWriterDelete.cs
index cb85a55..60df181 100644
--- a/src/Lucene.Net.Tests/core/Index/TestIndexWriterDelete.cs
+++ b/src/Lucene.Net.Tests/core/Index/TestIndexWriterDelete.cs
@@ -398,9 +398,9 @@ namespace Lucene.Net.Index
                     for (int j = 0; j < 1000; j++)
                     {
                         Document doc = new Document();
-                        doc.Add(NewTextField("content", "aaa", Field.Store.NO));
-                        doc.Add(NewStringField("id", Convert.ToString(id++), Field.Store.YES));
-                        doc.Add(NewStringField("value", Convert.ToString(value), Field.Store.NO));
+                        doc.Add(OuterInstance.NewTextField("content", "aaa", Field.Store.NO));
+                        doc.Add(OuterInstance.NewStringField("id", Convert.ToString(id++),
Field.Store.YES));
+                        doc.Add(OuterInstance.NewStringField("value", Convert.ToString(value),
Field.Store.NO));
                         if (DefaultCodecSupportsDocValues())
                         {
                             doc.Add(new NumericDocValuesField("dv", value));

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/95bd05b7/src/Lucene.Net.Tests/core/Index/TestIndexWriterExceptions.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Index/TestIndexWriterExceptions.cs b/src/Lucene.Net.Tests/core/Index/TestIndexWriterExceptions.cs
index d732cc5..2a927d9 100644
--- a/src/Lucene.Net.Tests/core/Index/TestIndexWriterExceptions.cs
+++ b/src/Lucene.Net.Tests/core/Index/TestIndexWriterExceptions.cs
@@ -181,13 +181,13 @@ namespace Lucene.Net.Index
             {
                 Document doc = new Document();
 
-                doc.Add(NewTextField(r, "content1", "aaa bbb ccc ddd", Field.Store.YES));
-                doc.Add(NewField(r, "content6", "aaa bbb ccc ddd", DocCopyIterator.Custom1));
-                doc.Add(NewField(r, "content2", "aaa bbb ccc ddd", DocCopyIterator.Custom2));
-                doc.Add(NewField(r, "content3", "aaa bbb ccc ddd", DocCopyIterator.Custom3));
+                doc.Add(OuterInstance.NewTextField(r, "content1", "aaa bbb ccc ddd", Field.Store.YES));
+                doc.Add(OuterInstance.NewField(r, "content6", "aaa bbb ccc ddd", DocCopyIterator.Custom1));
+                doc.Add(OuterInstance.NewField(r, "content2", "aaa bbb ccc ddd", DocCopyIterator.Custom2));
+                doc.Add(OuterInstance.NewField(r, "content3", "aaa bbb ccc ddd", DocCopyIterator.Custom3));
 
-                doc.Add(NewTextField(r, "content4", "aaa bbb ccc ddd", Field.Store.NO));
-                doc.Add(NewStringField(r, "content5", "aaa bbb ccc ddd", Field.Store.NO));
+                doc.Add(OuterInstance.NewTextField(r, "content4", "aaa bbb ccc ddd", Field.Store.NO));
+                doc.Add(OuterInstance.NewStringField(r, "content5", "aaa bbb ccc ddd", Field.Store.NO));
                 if (DefaultCodecSupportsDocValues())
                 {
                     doc.Add(new NumericDocValuesField("numericdv", 5));
@@ -200,9 +200,9 @@ namespace Lucene.Net.Index
                     doc.Add(new SortedSetDocValuesField("sortedsetdv", new BytesRef("again")));
                 }
 
-                doc.Add(NewField(r, "content7", "aaa bbb ccc ddd", DocCopyIterator.Custom4));
+                doc.Add(OuterInstance.NewField(r, "content7", "aaa bbb ccc ddd", DocCopyIterator.Custom4));
 
-                Field idField = NewField(r, "id", "", DocCopyIterator.Custom2);
+                Field idField = OuterInstance.NewField(r, "id", "", DocCopyIterator.Custom2);
                 doc.Add(idField);
 
                 long stopTime = ((long)(DateTime.UtcNow - unixEpoch).TotalMilliseconds) +
500;
@@ -1026,11 +1026,11 @@ namespace Lucene.Net.Index
                     for (int iter = 0; iter < NUM_ITER; iter++)
                     {
                         Document doc = new Document();
-                        doc.Add(NewField("contents", "here are some contents", DocCopyIterator.Custom5));
+                        doc.Add(OuterInstance.NewField("contents", "here are some contents",
DocCopyIterator.Custom5));
                         Writer.AddDocument(doc);
                         Writer.AddDocument(doc);
-                        doc.Add(NewField("crash", "this should crash after 4 terms", DocCopyIterator.Custom5));
-                        doc.Add(NewField("other", "this will not get indexed", DocCopyIterator.Custom5));
+                        doc.Add(OuterInstance.NewField("crash", "this should crash after
4 terms", DocCopyIterator.Custom5));
+                        doc.Add(OuterInstance.NewField("other", "this will not get indexed",
DocCopyIterator.Custom5));
                         try
                         {
                             Writer.AddDocument(doc);
@@ -1043,7 +1043,7 @@ namespace Lucene.Net.Index
                         if (0 == FinalI)
                         {
                             doc = new Document();
-                            doc.Add(NewField("contents", "here are some contents", DocCopyIterator.Custom5));
+                            doc.Add(OuterInstance.NewField("contents", "here are some contents",
DocCopyIterator.Custom5));
                             Writer.AddDocument(doc);
                             Writer.AddDocument(doc);
                         }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/95bd05b7/src/Lucene.Net.Tests/core/Index/TestIndexWriterWithThreads.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Index/TestIndexWriterWithThreads.cs b/src/Lucene.Net.Tests/core/Index/TestIndexWriterWithThreads.cs
index 0e1d1e7..d983d88 100644
--- a/src/Lucene.Net.Tests/core/Index/TestIndexWriterWithThreads.cs
+++ b/src/Lucene.Net.Tests/core/Index/TestIndexWriterWithThreads.cs
@@ -45,6 +45,7 @@ namespace Lucene.Net.Index
     using NumericDocValuesField = NumericDocValuesField;
     using TestUtil = Lucene.Net.Util.TestUtil;
     using TextField = TextField;
+    using Util;
 
     /// <summary>
     /// MultiThreaded IndexWriter tests
@@ -55,6 +56,8 @@ namespace Lucene.Net.Index
         // Used by test cases below
         private class IndexerThread : ThreadClass
         {
+            private readonly Func<string, string, FieldType, Field> NewField;
+
             internal bool DiskFull;
             internal Exception Error;
             internal AlreadyClosedException Ace;
@@ -62,10 +65,11 @@ namespace Lucene.Net.Index
             internal bool NoErrors;
             internal volatile int AddCount;
 
-            public IndexerThread(IndexWriter writer, bool noErrors)
+            public IndexerThread(IndexWriter writer, bool noErrors, Func<string, string,
FieldType, Field> newField)
             {
                 this.Writer = writer;
                 this.NoErrors = noErrors;
+                NewField = newField;
             }
 
             public override void Run()
@@ -168,7 +172,7 @@ namespace Lucene.Net.Index
 
                 for (int i = 0; i < NUM_THREADS; i++)
                 {
-                    threads[i] = new IndexerThread(writer, true);
+                    threads[i] = new IndexerThread(writer, true, NewField);
                 }
 
                 for (int i = 0; i < NUM_THREADS; i++)
@@ -219,7 +223,7 @@ namespace Lucene.Net.Index
 
                 for (int i = 0; i < NUM_THREADS; i++)
                 {
-                    threads[i] = new IndexerThread(writer, false);
+                    threads[i] = new IndexerThread(writer, false, NewField);
                 }
 
                 for (int i = 0; i < NUM_THREADS; i++)
@@ -303,7 +307,7 @@ namespace Lucene.Net.Index
 
                 for (int i = 0; i < NUM_THREADS; i++)
                 {
-                    threads[i] = new IndexerThread(writer, true);
+                    threads[i] = new IndexerThread(writer, true, NewField);
                 }
 
                 for (int i = 0; i < NUM_THREADS; i++)
@@ -555,8 +559,8 @@ namespace Lucene.Net.Index
         {
             Directory dir = NewDirectory();
             CountdownEvent oneIWConstructed = new CountdownEvent(1);
-            DelayedIndexAndCloseRunnable thread1 = new DelayedIndexAndCloseRunnable(dir,
oneIWConstructed);
-            DelayedIndexAndCloseRunnable thread2 = new DelayedIndexAndCloseRunnable(dir,
oneIWConstructed);
+            DelayedIndexAndCloseRunnable thread1 = new DelayedIndexAndCloseRunnable(dir,
oneIWConstructed, this);
+            DelayedIndexAndCloseRunnable thread2 = new DelayedIndexAndCloseRunnable(dir,
oneIWConstructed, this);
 
             thread1.Start();
             thread2.Start();
@@ -596,11 +600,13 @@ namespace Lucene.Net.Index
             internal Exception Failure = null;
             internal readonly CountdownEvent StartIndexing_Renamed = new CountdownEvent(1);
             internal CountdownEvent IwConstructed;
+            private readonly LuceneTestCase OuterInstance;
 
-            public DelayedIndexAndCloseRunnable(Directory dir, CountdownEvent iwConstructed)
+            public DelayedIndexAndCloseRunnable(Directory dir, CountdownEvent iwConstructed,
LuceneTestCase outerInstance)
             {
                 this.Dir = dir;
                 this.IwConstructed = iwConstructed;
+                OuterInstance = outerInstance;
             }
 
             public virtual void StartIndexing()
@@ -613,9 +619,9 @@ namespace Lucene.Net.Index
                 try
                 {
                     Document doc = new Document();
-                    Field field = NewTextField("field", "testData", Field.Store.YES);
+                    Field field = OuterInstance.NewTextField("field", "testData", Field.Store.YES);
                     doc.Add(field);
-                    IndexWriter writer = new IndexWriter(Dir, NewIndexWriterConfig(TEST_VERSION_CURRENT,
new MockAnalyzer(Random())));
+                    IndexWriter writer = new IndexWriter(Dir, OuterInstance.NewIndexWriterConfig(TEST_VERSION_CURRENT,
new MockAnalyzer(Random())));
                     IwConstructed.Signal();
                     StartIndexing_Renamed.Wait();
                     writer.AddDocument(doc);
@@ -718,7 +724,7 @@ namespace Lucene.Net.Index
                                         Console.WriteLine("TEST: " + Thread.CurrentThread.Name
+ ": rollback done; now open new writer");
                                     }
                                     WriterRef.Value = 
-                                        new IndexWriter(d, NewIndexWriterConfig(TEST_VERSION_CURRENT,
new MockAnalyzer(Random())));
+                                        new IndexWriter(d, OuterInstance.NewIndexWriterConfig(TEST_VERSION_CURRENT,
new MockAnalyzer(Random())));
                                 }
                                 finally
                                 {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/95bd05b7/src/Lucene.Net.Tests/core/Index/TestIndexableField.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Index/TestIndexableField.cs b/src/Lucene.Net.Tests/core/Index/TestIndexableField.cs
index 8059126..cce7ca3 100644
--- a/src/Lucene.Net.Tests/core/Index/TestIndexableField.cs
+++ b/src/Lucene.Net.Tests/core/Index/TestIndexableField.cs
@@ -423,7 +423,7 @@ namespace Lucene.Net.Index
                     if (fieldUpto == 0)
                     {
                         fieldUpto = 1;
-                        current = NewStringField("id", "" + OuterInstance.FinalDocCount,
Field.Store.YES);
+                        current = OuterTextIndexableField.NewStringField("id", "" + OuterInstance.FinalDocCount,
Field.Store.YES);
                     }
                     else
                     {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/95bd05b7/src/Lucene.Net.Tests/core/Index/TestNeverDelete.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Index/TestNeverDelete.cs b/src/Lucene.Net.Tests/core/Index/TestNeverDelete.cs
index 61a5105..74db3bb 100644
--- a/src/Lucene.Net.Tests/core/Index/TestNeverDelete.cs
+++ b/src/Lucene.Net.Tests/core/Index/TestNeverDelete.cs
@@ -61,7 +61,7 @@ namespace Lucene.Net.Index
             long stopTime = Environment.TickCount + AtLeast(1000);
             for (int x = 0; x < indexThreads.Length; x++)
             {
-                indexThreads[x] = new ThreadAnonymousInnerClassHelper(w, stopTime);
+                indexThreads[x] = new ThreadAnonymousInnerClassHelper(w, stopTime, NewStringField,
NewTextField);
                 indexThreads[x].Name = "Thread " + x;
                 indexThreads[x].Start();
             }
@@ -104,13 +104,19 @@ namespace Lucene.Net.Index
 
         private class ThreadAnonymousInnerClassHelper : ThreadClass
         {
+            private readonly Func<string, string, Field.Store, Field> NewStringField;
+            private readonly Func<string, string, Field.Store, Field> NewTextField;
+
             private RandomIndexWriter w;
             private long StopTime;
 
-            public ThreadAnonymousInnerClassHelper(RandomIndexWriter w, long stopTime)
+            public ThreadAnonymousInnerClassHelper(RandomIndexWriter w, long stopTime, 
+                Func<string, string, Field.Store, Field> newStringField, Func<string,
string, Field.Store, Field> newTextField)
             {
                 this.w = w;
                 this.StopTime = stopTime;
+                NewStringField = newStringField;
+                NewTextField = newTextField;
             }
 
             public override void Run()

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/95bd05b7/src/Lucene.Net.Tests/core/Index/TestRollingUpdates.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Index/TestRollingUpdates.cs b/src/Lucene.Net.Tests/core/Index/TestRollingUpdates.cs
index 8032dfc..804822c 100644
--- a/src/Lucene.Net.Tests/core/Index/TestRollingUpdates.cs
+++ b/src/Lucene.Net.Tests/core/Index/TestRollingUpdates.cs
@@ -204,7 +204,7 @@ namespace Lucene.Net.Index
                 IndexingThread[] threads = new IndexingThread[numThreads];
                 for (int i = 0; i < numThreads; i++)
                 {
-                    threads[i] = new IndexingThread(docs, w, numUpdates);
+                    threads[i] = new IndexingThread(docs, w, numUpdates, NewStringField);
                     threads[i].Start();
                 }
 
@@ -229,12 +229,15 @@ namespace Lucene.Net.Index
             internal readonly IndexWriter Writer;
             internal readonly int Num;
 
-            public IndexingThread(LineFileDocs docs, IndexWriter writer, int num)
+            private readonly Func<string, string, Field.Store, Field> NewStringField;
+
+            public IndexingThread(LineFileDocs docs, IndexWriter writer, int num, Func<string,
string, Field.Store, Field> newStringField)
                 : base()
             {
                 this.Docs = docs;
                 this.Writer = writer;
                 this.Num = num;
+                NewStringField = newStringField;
             }
 
             public override void Run()

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/95bd05b7/src/Lucene.Net.Tests/core/Index/TestSnapshotDeletionPolicy.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Index/TestSnapshotDeletionPolicy.cs b/src/Lucene.Net.Tests/core/Index/TestSnapshotDeletionPolicy.cs
index b03b743..682e1cc 100644
--- a/src/Lucene.Net.Tests/core/Index/TestSnapshotDeletionPolicy.cs
+++ b/src/Lucene.Net.Tests/core/Index/TestSnapshotDeletionPolicy.cs
@@ -148,7 +148,7 @@ namespace Lucene.Net.Index
             dp = (SnapshotDeletionPolicy)writer.Config.DelPolicy;
             writer.Commit();
 
-            ThreadClass t = new ThreadAnonymousInnerClassHelper(stopTime, writer);
+            ThreadClass t = new ThreadAnonymousInnerClassHelper(stopTime, writer, NewField);
 
             t.Start();
 
@@ -183,11 +183,13 @@ namespace Lucene.Net.Index
         {
             private long StopTime;
             private IndexWriter Writer;
+            private readonly Func<string, string, FieldType, Field> _newFieldFunc;
 
-            public ThreadAnonymousInnerClassHelper(long stopTime, IndexWriter writer)
+            public ThreadAnonymousInnerClassHelper(long stopTime, IndexWriter writer, Func<string,
string, FieldType, Field> newFieldFunc)
             {
                 this.StopTime = stopTime;
                 this.Writer = writer;
+                _newFieldFunc = newFieldFunc;
             }
 
             public override void Run()
@@ -197,7 +199,7 @@ namespace Lucene.Net.Index
                 customType.StoreTermVectors = true;
                 customType.StoreTermVectorPositions = true;
                 customType.StoreTermVectorOffsets = true;
-                doc.Add(NewField("content", "aaa", customType));
+                doc.Add(_newFieldFunc("content", "aaa", customType));
                 do
                 {
                     for (int i = 0; i < 27; i++)

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/95bd05b7/src/Lucene.Net.Tests/core/Index/TestStressIndexing.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Index/TestStressIndexing.cs b/src/Lucene.Net.Tests/core/Index/TestStressIndexing.cs
index 8f271f3..f594fdc 100644
--- a/src/Lucene.Net.Tests/core/Index/TestStressIndexing.cs
+++ b/src/Lucene.Net.Tests/core/Index/TestStressIndexing.cs
@@ -89,6 +89,9 @@ namespace Lucene.Net.Index
 
         private class IndexerThread : TimedThread
         {
+            private readonly Func<string, string, Field.Store, Field> NewStringFieldFunc;
+            private readonly Func<string, string, Field.Store, Field> NewTextFieldFunc;
+
             internal IndexWriter Writer;
             internal int NextID;
 
@@ -98,8 +101,8 @@ namespace Lucene.Net.Index
                 : base(threads)
             {
                 this.Writer = writer;
-                NewStringField = newStringField;
-                NewTextField = newTextField;
+                NewStringFieldFunc = newStringField;
+                NewTextFieldFunc = newTextField;
             }
 
             public override void DoWork()
@@ -109,8 +112,8 @@ namespace Lucene.Net.Index
                 {
                     Documents.Document d = new Documents.Document();
                     int n = Random().Next();
-                    d.Add(NewStringField("id", Convert.ToString(NextID++), Field.Store.YES));
-                    d.Add(NewTextField("contents", English.IntToEnglish(n), Field.Store.NO));
+                    d.Add(NewStringFieldFunc("id", Convert.ToString(NextID++), Field.Store.YES));
+                    d.Add(NewTextFieldFunc("contents", English.IntToEnglish(n), Field.Store.NO));
                     Writer.AddDocument(d);
                 }
 
@@ -161,11 +164,11 @@ namespace Lucene.Net.Index
 
             // One modifier that writes 10 docs then removes 5, over
             // and over:
-            IndexerThread indexerThread = new IndexerThread(modifier, threads);
+            IndexerThread indexerThread = new IndexerThread(modifier, threads, NewStringField,
NewTextField);
             threads[numThread++] = indexerThread;
             indexerThread.Start();
 
-            IndexerThread indexerThread2 = new IndexerThread(modifier, threads);
+            IndexerThread indexerThread2 = new IndexerThread(modifier, threads, NewStringField,
NewTextField);
             threads[numThread++] = indexerThread2;
             indexerThread2.Start();
 

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/95bd05b7/src/Lucene.Net.Tests/core/Index/TestStressIndexing2.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Index/TestStressIndexing2.cs b/src/Lucene.Net.Tests/core/Index/TestStressIndexing2.cs
index cc9fc39..f335a90 100644
--- a/src/Lucene.Net.Tests/core/Index/TestStressIndexing2.cs
+++ b/src/Lucene.Net.Tests/core/Index/TestStressIndexing2.cs
@@ -917,7 +917,7 @@ namespace Lucene.Net.Index
 
                 List<Field> fields = new List<Field>();
                 string idString = IdString;
-                Field idField = NewField("id", idString, customType1);
+                Field idField = OuterInstance.NewField("id", idString, customType1);
                 fields.Add(idField);
 
                 int nFields = NextInt(MaxFields);
@@ -950,13 +950,13 @@ namespace Lucene.Net.Index
                             customType.Stored = true;
                             customType.OmitNorms = true;
                             customType.Indexed = true;
-                            fields.Add(NewField("f" + NextInt(100), GetString(1), customType));
+                            fields.Add(OuterInstance.NewField("f" + NextInt(100), GetString(1),
customType));
                             break;
 
                         case 1:
                             customType.Indexed = true;
                             customType.Tokenized = true;
-                            fields.Add(NewField("f" + NextInt(100), GetString(0), customType));
+                            fields.Add(OuterInstance.NewField("f" + NextInt(100), GetString(0),
customType));
                             break;
 
                         case 2:
@@ -964,14 +964,14 @@ namespace Lucene.Net.Index
                             customType.StoreTermVectors = false;
                             customType.StoreTermVectorOffsets = false;
                             customType.StoreTermVectorPositions = false;
-                            fields.Add(NewField("f" + NextInt(100), GetString(0), customType));
+                            fields.Add(OuterInstance.NewField("f" + NextInt(100), GetString(0),
customType));
                             break;
 
                         case 3:
                             customType.Stored = true;
                             customType.Indexed = true;
                             customType.Tokenized = true;
-                            fields.Add(NewField("f" + NextInt(100), GetString(BigFieldSize),
customType));
+                            fields.Add(OuterInstance.NewField("f" + NextInt(100), GetString(BigFieldSize),
customType));
                             break;
                     }
                 }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/95bd05b7/src/Lucene.Net.Tests/core/Index/TestStressNRT.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Index/TestStressNRT.cs b/src/Lucene.Net.Tests/core/Index/TestStressNRT.cs
index b514ec0..af8649a 100644
--- a/src/Lucene.Net.Tests/core/Index/TestStressNRT.cs
+++ b/src/Lucene.Net.Tests/core/Index/TestStressNRT.cs
@@ -337,8 +337,8 @@ namespace Lucene.Net.Index
                                     if (Tombstones)
                                     {
                                         Document d = new Document();
-                                        d.Add(NewStringField("id", "-" + Convert.ToString(id),
Documents.Field.Store.YES));
-                                        d.Add(NewField(OuterInstance.Field, Convert.ToString(nextVal),
StoredOnlyType));
+                                        d.Add(OuterInstance.NewStringField("id", "-" + Convert.ToString(id),
Documents.Field.Store.YES));
+                                        d.Add(OuterInstance.NewField(OuterInstance.Field,
Convert.ToString(nextVal), StoredOnlyType));
                                         Writer.UpdateDocument(new Term("id", "-" + Convert.ToString(id)),
d);
                                     }
 
@@ -357,8 +357,8 @@ namespace Lucene.Net.Index
                                     if (Tombstones)
                                     {
                                         Document d = new Document();
-                                        d.Add(NewStringField("id", "-" + Convert.ToString(id),
Documents.Field.Store.YES));
-                                        d.Add(NewField(OuterInstance.Field, Convert.ToString(nextVal),
StoredOnlyType));
+                                        d.Add(OuterInstance.NewStringField("id", "-" + Convert.ToString(id),
Documents.Field.Store.YES));
+                                        d.Add(OuterInstance.NewField(OuterInstance.Field,
Convert.ToString(nextVal), StoredOnlyType));
                                         Writer.UpdateDocument(new Term("id", "-" + Convert.ToString(id)),
d);
                                     }
 
@@ -373,8 +373,8 @@ namespace Lucene.Net.Index
                                 {
                                     // assertU(adoc("id",Integer.toString(id), field, Long.toString(nextVal)));
                                     Document d = new Document();
-                                    d.Add(NewStringField("id", Convert.ToString(id), Documents.Field.Store.YES));
-                                    d.Add(NewField(OuterInstance.Field, Convert.ToString(nextVal),
StoredOnlyType));
+                                    d.Add(OuterInstance.NewStringField("id", Convert.ToString(id),
Documents.Field.Store.YES));
+                                    d.Add(OuterInstance.NewField(OuterInstance.Field, Convert.ToString(nextVal),
StoredOnlyType));
                                     if (VERBOSE)
                                     {
                                         Console.WriteLine("TEST: " + Thread.CurrentThread.Name
+ ": u id:" + id + " val=" + nextVal);

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/95bd05b7/src/Lucene.Net.Tests/core/Index/TestThreadedForceMerge.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Index/TestThreadedForceMerge.cs b/src/Lucene.Net.Tests/core/Index/TestThreadedForceMerge.cs
index 7fddf19..2a7914d 100644
--- a/src/Lucene.Net.Tests/core/Index/TestThreadedForceMerge.cs
+++ b/src/Lucene.Net.Tests/core/Index/TestThreadedForceMerge.cs
@@ -148,8 +148,8 @@ namespace Lucene.Net.Index
                         for (int k = 0; k < 17 * (1 + IFinal); k++)
                         {
                             Document d = new Document();
-                            d.Add(NewField("id", IterFinal + "_" + IFinal + "_" + j + "_"
+ k, CustomType));
-                            d.Add(NewField("contents", English.IntToEnglish(IFinal + k),
CustomType));
+                            d.Add(OuterInstance.NewField("id", IterFinal + "_" + IFinal +
"_" + j + "_" + k, CustomType));
+                            d.Add(OuterInstance.NewField("contents", English.IntToEnglish(IFinal
+ k), CustomType));
                             WriterFinal.AddDocument(d);
                         }
                         for (int k = 0; k < 9 * (1 + IFinal); k++)

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/95bd05b7/src/Lucene.Net.Tests/core/Index/TestTransactions.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Index/TestTransactions.cs b/src/Lucene.Net.Tests/core/Index/TestTransactions.cs
index 0bba56f..a6d4635 100644
--- a/src/Lucene.Net.Tests/core/Index/TestTransactions.cs
+++ b/src/Lucene.Net.Tests/core/Index/TestTransactions.cs
@@ -201,8 +201,8 @@ namespace Lucene.Net.Index
                 {
                     Document d = new Document();
                     int n = Random().Next();
-                    d.Add(NewField("id", Convert.ToString(NextID++), customType));
-                    d.Add(NewTextField("contents", English.IntToEnglish(n), Field.Store.NO));
+                    d.Add(OuterInstance.NewField("id", Convert.ToString(NextID++), customType));
+                    d.Add(OuterInstance.NewTextField("contents", English.IntToEnglish(n),
Field.Store.NO));
                     writer.AddDocument(d);
                 }
 

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/95bd05b7/src/Lucene.Net.Tests/core/Store/TestRAMDirectory.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Store/TestRAMDirectory.cs b/src/Lucene.Net.Tests/core/Store/TestRAMDirectory.cs
index 7fa05f4..114a995 100644
--- a/src/Lucene.Net.Tests/core/Store/TestRAMDirectory.cs
+++ b/src/Lucene.Net.Tests/core/Store/TestRAMDirectory.cs
@@ -158,7 +158,7 @@ namespace Lucene.Net.Store
                 for (int j = 1; j < OuterInstance.DocsPerThread; j++)
                 {
                     Document doc = new Document();
-                    doc.Add(NewStringField("sizeContent", English.IntToEnglish(Num * OuterInstance.DocsPerThread
+ j).Trim(), Field.Store.YES));
+                    doc.Add(OuterInstance.NewStringField("sizeContent", English.IntToEnglish(Num
* OuterInstance.DocsPerThread + j).Trim(), Field.Store.YES));
                     try
                     {
                         Writer.AddDocument(doc);


Mime
View raw message