You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucenenet.apache.org by "Philip Todd (JIRA)" <ji...@apache.org> on 2009/02/27 11:16:18 UTC

[jira] Created: (LUCENENET-174) RAMDirectory Not Correctly Serilizing

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


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.


RE: [jira] Commented: (LUCENENET-174) RAMDirectory Not Correctly Serilizing

Posted by Digy <di...@gmail.com>.
I am personally using TortoiseSVN to update/commit/create patch etc. (http://tortoisesvn.tigris.org/)
But there are also many other solutions available for free.

DIGY.

-----Original Message-----
From: Philip Todd (JIRA) [mailto:jira@apache.org] 
Sent: Tuesday, March 10, 2009 5:53 PM
To: lucene-net-dev@incubator.apache.org
Subject: [jira] Commented: (LUCENENET-174) RAMDirectory Not Correctly Serilizing


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

Philip Todd commented on LUCENENET-174:
---------------------------------------

Thanks DIGY,

Your fix seems to be working fine. 

For future reference - as I'll be using Lucene.Net for some time now with this new application (and probably more in future), can you point me to some info about how to create a ".diff" or ".patch" file?


Cheers,
Phil



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


[jira] Issue Comment Edited: (LUCENENET-174) RAMDirectory Not Correctly Serilizing

Posted by "Philip Todd (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LUCENENET-174?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12680417#action_12680417 ] 

Philip Todd edited comment on LUCENENET-174 at 3/10/09 3:14 AM:
----------------------------------------------------------------

I'm not sure what the procedure is (if any) for submitting patches so I'm attaching 3 files containing a fix for the bug. They are in a zip file. They should all be placed in the Store directory.

Directory.cs
LockFactory.cs
SingleInstanceLockFactory.cs

Please let me know if I can do anything else.



      was (Author: philip.todd):
    3 files containing fix for error serializing RamDirectory:
Directory.cs
LockFactory.cs
singleInstanceLockFactory.cs


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


[jira] Closed: (LUCENENET-174) RAMDirectory Not Correctly Serilizing

Posted by "Digy (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LUCENENET-174?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Digy closed LUCENENET-174.
--------------------------

    Resolution: Fixed
      Assignee: Digy

Patch applied.

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


[jira] Commented: (LUCENENET-174) RAMDirectory Not Correctly Serilizing

Posted by "Digy (JIRA)" <ji...@apache.org>.
    [ 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.


[jira] Commented: (LUCENENET-174) RAMDirectory Not Correctly Serilizing

Posted by "Philip Todd (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LUCENENET-174?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12680517#action_12680517 ] 

Philip Todd commented on LUCENENET-174:
---------------------------------------

Thanks DIGY,

Your fix seems to be working fine. 

For future reference - as I'll be using Lucene.Net for some time now with this new application (and probably more in future), can you point me to some info about how to create a ".diff" or ".patch" file?


Cheers,
Phil



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


[jira] Updated: (LUCENENET-174) RAMDirectory Not Correctly Serilizing

Posted by "Digy (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LUCENENET-174?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Digy updated LUCENENET-174:
---------------------------

    Attachment: RAMDirectory.patch

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


[jira] Commented: (LUCENENET-174) RAMDirectory Not Correctly Serilizing

Posted by "Digy (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LUCENENET-174?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12679326#action_12679326 ] 

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

Hi Philip,

RAMDirectory in Lucene.Java implements  "Serializable" ( http://lucene.apache.org/java/2_3_2/api/org/apache/lucene/store/RAMDirectory.html).
Therefore, Lucene.Net should also be serializable.

Can you submit a patch for this?

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


[jira] Commented: (LUCENENET-174) RAMDirectory Not Correctly Serilizing

Posted by "Digy (JIRA)" <ji...@apache.org>.
    [ 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.


[jira] Updated: (LUCENENET-174) RAMDirectory Not Correctly Serilizing

Posted by "Philip Todd (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LUCENENET-174?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Philip Todd updated LUCENENET-174:
----------------------------------

    Attachment: Store.zip

3 files containing fix for error serializing RamDirectory:
Directory.cs
LockFactory.cs
singleInstanceLockFactory.cs



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