lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From synhers...@apache.org
Subject [09/18] lucenenet git commit: Fixed bugs in TestOpenIfChangedMergedSegment() and TestOpenIfChangedNoChangesButSegmentMerges() in Facet.Taxonomy.Directory.TestDirectoryTaxonomyReader that caused them to throw null reference exceptions and fail.
Date Sun, 21 Aug 2016 06:54:48 GMT
Fixed bugs in TestOpenIfChangedMergedSegment() and  TestOpenIfChangedNoChangesButSegmentMerges()
in Facet.Taxonomy.Directory.TestDirectoryTaxonomyReader that caused them to throw null reference
exceptions and fail.


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

Branch: refs/heads/master
Commit: 1727c1b3f84562d3718a7de0b86b51712507d26a
Parents: 694676c
Author: Shad Storhaug <shad@shadstorhaug.com>
Authored: Sun Aug 21 09:47:53 2016 +0700
Committer: Shad Storhaug <shad@shadstorhaug.com>
Committed: Sun Aug 21 09:47:53 2016 +0700

----------------------------------------------------------------------
 .../Directory/TestDirectoryTaxonomyReader.cs    | 32 +++++++++++---------
 1 file changed, 17 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/1727c1b3/src/Lucene.Net.Tests.Facet/Taxonomy/Directory/TestDirectoryTaxonomyReader.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Facet/Taxonomy/Directory/TestDirectoryTaxonomyReader.cs
b/src/Lucene.Net.Tests.Facet/Taxonomy/Directory/TestDirectoryTaxonomyReader.cs
index 15f30df..74ba8fe 100644
--- a/src/Lucene.Net.Tests.Facet/Taxonomy/Directory/TestDirectoryTaxonomyReader.cs
+++ b/src/Lucene.Net.Tests.Facet/Taxonomy/Directory/TestDirectoryTaxonomyReader.cs
@@ -297,7 +297,12 @@ namespace Lucene.Net.Facet.Taxonomy.Directory
             // hold onto IW to forceMerge
             // note how we don't close it, since DTW will close it.
             IndexWriter iw = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT,
new MockAnalyzer(Random())).SetMergePolicy(new LogByteSizeMergePolicy()));
-            var writer = new DirectoryTaxonomyWriterAnonymousInnerClassHelper2(this, dir,
iw) as DirectoryTaxonomyWriter;
+
+            // LUCENENET: We need to set the index writer before the constructor of the base
class is called
+            // because the DirectoryTaxonomyWriter class constructor is the consumer of the
OpenIndexWriter method.
+            // The only option seems to be to set it statically before creating the instance.
+            DirectoryTaxonomyWriterAnonymousInnerClassHelper2.iw = iw;
+            var writer = new DirectoryTaxonomyWriterAnonymousInnerClassHelper2(dir);
 
             var reader = new DirectoryTaxonomyReader(writer);
             Assert.AreEqual(1, reader.Size);
@@ -323,15 +328,11 @@ namespace Lucene.Net.Facet.Taxonomy.Directory
 
         private class DirectoryTaxonomyWriterAnonymousInnerClassHelper2 : DirectoryTaxonomyWriter
         {
-            private readonly TestDirectoryTaxonomyReader outerInstance;
-
-            private IndexWriter iw;
-            private IndexWriterConfig config;
+            internal static IndexWriter iw = null;
 
-            public DirectoryTaxonomyWriterAnonymousInnerClassHelper2(TestDirectoryTaxonomyReader
outerInstance, Directory dir, IndexWriter iw) : base(dir)
+            public DirectoryTaxonomyWriterAnonymousInnerClassHelper2(Directory dir) 
+                : base(dir)
             {
-                this.outerInstance = outerInstance;
-                this.iw = iw;
             }
 
             protected override IndexWriter OpenIndexWriter(Directory directory, IndexWriterConfig
config) 
@@ -352,7 +353,12 @@ namespace Lucene.Net.Facet.Taxonomy.Directory
             // hold onto IW to forceMerge
             // note how we don't close it, since DTW will close it.
             var iw = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, new
MockAnalyzer(Random())).SetMergePolicy(new LogByteSizeMergePolicy()));
-            DirectoryTaxonomyWriter writer = new DirectoryTaxonomyWriterAnonymousInnerClassHelper3(this,
dir, iw);
+
+            // LUCENENET: We need to set the index writer before the constructor of the base
class is called
+            // because the DirectoryTaxonomyWriter class constructor is the consumer of the
OpenIndexWriter method.
+            // The only option seems to be to set it statically before creating the instance.
+            DirectoryTaxonomyWriterAnonymousInnerClassHelper3.iw = iw;
+            DirectoryTaxonomyWriter writer = new DirectoryTaxonomyWriterAnonymousInnerClassHelper3(dir);
 
 
             // add a category so that the following DTR open will cause a flush and 
@@ -381,15 +387,11 @@ namespace Lucene.Net.Facet.Taxonomy.Directory
 
         private class DirectoryTaxonomyWriterAnonymousInnerClassHelper3 : DirectoryTaxonomyWriter
         {
-            private readonly TestDirectoryTaxonomyReader outerInstance;
+            internal static IndexWriter iw;
 
-            private IndexWriter iw;
-
-            public DirectoryTaxonomyWriterAnonymousInnerClassHelper3(TestDirectoryTaxonomyReader
outerInstance, Directory dir, IndexWriter iw)
+            public DirectoryTaxonomyWriterAnonymousInnerClassHelper3(Directory dir)
                 : base(dir)
             {
-                this.outerInstance = outerInstance;
-                this.iw = iw;
             }
 
             protected override IndexWriter OpenIndexWriter(Directory directory, IndexWriterConfig
config)


Mime
View raw message