[ https://issues.apache.org/jira/browse/LUCENENET-174?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12680565#action_12680565 ]
Digy commented on LUCENENET-174: -------------------------------- If there are no objections, I'll commit the patch DIGY > RAMDirectory Not Correctly Serilizing > ------------------------------------- > > Key: LUCENENET-174 > URL: https://issues.apache.org/jira/browse/LUCENENET-174 > Project: Lucene.Net > Issue Type: Bug > Environment: Lucene.Net version 2.1 > Windows XP 64Bit SP2 > Visual Studio 2008 SP1 > DOTNET 3.5 SP1 > NCache Developer 3.4 > Reporter: Philip Todd > Priority: Minor > Attachments: RAMDirectory.patch, Store.zip > > Original Estimate: 0.17h > Remaining Estimate: 0.17h > > Greetings. Firstly a big thank you for everyones efforts with Lucene and > Lucene.Net. Your efforts are much appreciated. > Background: > I have created a server application which allows searching across many > companies. In order to achieve this I have utilized Lucene.Net for indexing > and searching and NCache from Alachisoft for caching the information > server-side. As the Lucene index takes a fair amount of time to create - I am > also caching the RAMDirectory. The caching requires all objects to be > serialized before storage. > The issue: > After retrieving the RAMDirectory from cache (after de-serializing) I > attempted to create a new IndexWriter object to allow adding more items to > the index: > oDirectory = CacheConfig.DeCacheSupplierIndex("SupplierIndex" & > Supplier.BuyerNo) > analyzer = New StandardAnalyzer() > oIndexWriter = New IndexWriter(oDirectory, analyzer, False) > The attempt to create the IndexWriter resulted in a NullReference exception > at: > at Lucene.Net.Store.Directory.MakeLock(String name) > at Lucene.Net.Index.IndexWriter.Init(Directory d, Analyzer a, > Boolean create, Boolean closeDir) > at Lucene.Net.Index.IndexWriter..ctor(Directory d, Analyzer a) > > After debugging the Lucene source I discovered the exception was caused by > the lockFactory definition in the Directory class (Directory.cs line 49) > having a [NonSerialized] attribute. This caused the lockFactory to be null > after serialization. > Fix: > Removed the [NonSerialized] attribute. > Added a [Serializable] attribute to SingleInstanceLockFactory > (SingleInstanceLockFactory.cs line 35) > Added a [Serializable] attribute to LockFactory (LockFactory.cs line 28) > This allowed me to proceed. I have not thoroughly tested the changes. I can > provide the source code if required. > As we will very likely upgrade to future versions of Lucene - I would like to > have any fix incorporated into the Lucene source repository. Let me know what > I should do. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.