NightOwl888 opened a new issue #408: URL: https://github.com/apache/lucenenet/issues/408
In [this test scenario](https://github.com/apache/lucenenet/blob/ae13dc4dfe0b8a2d305b9f8f860ac0849a16ac80/src/Lucene.Net.Tests.Facet/Taxonomy/Directory/TestDirectoryTaxonomyReader.cs#L298-L302), an alternate `IndexWriter` is being setup to be returned from the `OpenIndexWriter` method. However, since the constructor of the class calls `OpenIndexWriter` there is an issue where it cannot be extended directly as it was intended in Java. A constructor of a base class always runs before the subclass, so there is a chicken and egg problem with overriding `OpenIndexWriter`. The current "solution" uses a static variable to set the `iw` variable before instantiating the class. ```c# private class DirectoryTaxonomyWriterAnonymousInnerClassHelper2 : DirectoryTaxonomyWriter { internal static IndexWriter iw = null; public DirectoryTaxonomyWriterAnonymousInnerClassHelper2(Directory dir) : base(dir) { } protected override IndexWriter OpenIndexWriter(Directory directory, IndexWriterConfig config) { return iw; } } ``` While this makes the test pass, it clearly is going to be an issue for concurrent environments to do it this way. We need to find a solution that allows using instance variables throughout, even if it means diverging a little from the original Lucene design. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected]
