Hmm...well my implementation is too layered to allow for a try/catch to
correctly ensure that IndexWriter.Close is called, so I'm pretty much
forced to use IDisposable / finalizer.  I'm just surprised that
IndexWriter itself doesn't do this work.  Generally the expectation is
that if a managed class manages an unmanaged resource such as a file on
disk, that it cleans up after itself in a finalizer.

Thanks for the response.  It sounds like I'm not missing anything and
this is just the way things are.

~ Justin

-----Original Message-----
From: Brian Sayatovic [mailto:[email protected]] 
Sent: Friday, June 01, 2012 1:44 PM
To: [email protected]
Subject: RE: Implementing IDisposable / finalizer pattern to avoid index
lock issues

I use a try/finally myself, with some extension methods to wrap it.  My
understanding is that IDisposable is wrought with trouble.  My Lucene
access is wrapped in an agent class, and my syntax ends up looking like
DoWithAgent(agent => agent.UpdateIndex(foo));

Brian Sayatovic
Senior Software Architect

866-218-1003 toll-free ext. 8936
937-235-8936 office
4540 Honeywell Ct. Dayton, OH 45424


This message may contain confidential/proprietary information from the
CINgroup or its subsidiaries.
If you are not an intended recipient, please refrain from the
disclosure, copying, distribution or use of this information. All such
unauthorized actions are strictly prohibited. If you have received this
transmission in error, please notify the sender by e-mail and delete all
copies of this material from any computer.


-----Original Message-----
From: Kohlhepp, Justin W (Heritage Holdings (HHI))
[mailto:[email protected]]

I was surprised to notice that IndexWriter does not implement
IDisposable.  It seems that the user is responsible for guaranteeing
that IndexWriter.Close is called and that IndexWriter itself does not do
this in a Dispose or destructor method.  Do I have this understanding
correct?  I wrote a wrapper around Lucene.NET for my application and was
forced to implement IDisposable / finalizer in order for index to unlock
correctly.  Is this the expected pattern?
************************************************************
This communication, including attachments, is for the exclusive use of 
addressee and may contain proprietary, confidential and/or privileged 
information.  If you are not the intended recipient, any use, copying, 
disclosure, dissemination or distribution is strictly prohibited.  If you are 
not the intended recipient, please notify the sender immediately by return 
e-mail, delete this communication and destroy all copies.
************************************************************

Reply via email to