lucenenet-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Digy (JIRA)" <j...@apache.org>
Subject [jira] Commented: (LUCENENET-174) RAMDirectory Not Correctly Serilizing
Date Tue, 10 Mar 2009 13:20:50 GMT

    [ https://issues.apache.org/jira/browse/LUCENENET-174?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12680457#action_12680457
] 

Digy commented on LUCENENET-174:
--------------------------------

Hi Philip, 

1- Submitting patches as ".patch" or ".diff" files makes it easier to locate the changes made
in original files.

2- The problem with the deserialization of RAMDirectory(using binary/soap formatter) is that
the default constructor is not called after deserialization process(and lockFactory is not
initialized).
Therefore adding a simple code to RAMDirectory like below
{code}
[System.Runtime.Serialization.OnDeserialized]
void OnDeserialized(System.Runtime.Serialization.StreamingContext context)
{
   if (lockFactory == null)
   {
      SetLockFactory(new SingleInstanceLockFactory());
   }
}
{code}
can solve the problem. (I don't see any advantage in making the lackFactory serializable especially
across machine boundries).

Can you test this code?

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: 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.


Mime
View raw message