Skip to content

NullReferenceException in DefaultCodecFactory.Initialize #1223

@nasirodin

Description

@nasirodin

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

When creating an IndexWriterConfig (Lucene.NET 4.8 beta) and initializing Lucene, DefaultCodecFactory.Initialize() can throw an unhandled NullReferenceException. The stack trace shows the exception originates from NamedServiceFactory.CodecsAssembly, which calls Type.GetType(...).

Expected Behavior

No response

Steps To Reproduce

private const LuceneVersion Version = LuceneVersion.LUCENE_48;

_analyzer = new PerFieldAnalyzerWrapper(new StandardAnalyzer(Version), analyzerMap);

IndexWriterConfig indexConfig = new(Version, _analyzer)
{
    Codec = new Lucene46Codec()
};

_writer = new IndexWriter(_directory, indexConfig);

Exceptions (if any)

System.NullReferenceException: Object reference not set to an instance of an object.
   at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMarkHandle stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName, ObjectHandleOnStack type)
   at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName)
   at System.Type.GetType(String typeName)
   at Lucene.Net.Util.NamedServiceFactory`1.get_CodecsAssembly()
   at Lucene.Net.Codecs.DefaultCodecFactory.Initialize()
   at Lucene.Net.Util.NamedServiceFactory`1.<EnsureInitialized>b__4_0()
   at System.Threading.LazyInitializer.EnsureInitializedCore[T](T& target, Boolean& initialized, Object& syncLock, Func`1 valueFactory)
   at Lucene.Net.Util.NamedServiceFactory`1.EnsureInitialized()
   at Lucene.Net.Codecs.DefaultCodecFactory.GetCodec(String name)
   at Lucene.Net.Codecs.Codec.get_Default()
   at Lucene.Net.Index.LiveIndexWriterConfig..ctor(Analyzer analyzer, LuceneVersion matchVersion)
   at BIMLOGiQ.CopilotPlugin.FullIndexSearch.LuceneSearch`1..ctor()
   at BIMLOGiQ.CopilotPlugin.Services.Symbols.SymbolCache..ctor(ICommandExtenderService commandExtenderService, IEnumerable`1 symbolItems, IEnumerable`1 symbolCategories)
   at BIMLOGiQ.CopilotPlugin.Services.Symbols.SymbolService.<>c__DisplayClass13_0.<EnsureBuildSymbolCache>b__1(UIApplication app)
   at Revit.Async.RevitTask.<>c__DisplayClass20_0.<RunAsync>b__0(UIApplication app)
   at Revit.Async.Extensions.ExternalEventResultHandlerExtensions.Wait[TResult](IExternalEventResultHandler`1 resultHandler, Func`1 function)

Lucene.NET Version

4.8.0-beta00016

.NET Version

net48

Operating System

No response

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions