paulirwin opened a new issue, #1073:
URL: https://github.com/apache/lucenenet/issues/1073

   ### Is there an existing issue for this?
   
   - [X] I have searched the existing issues
   
   ### Task description
   
   From investigating #265:
   
   > I have also been made aware that there is at least one class 
(Lucene.Net.Store.Lock, if I recall correctly) that is designed to be re-opened 
after it is closed.
   
   In investigating the Lock class, I found that in later versions of Lucene, 
[the Lock API was 
simplified](https://github.com/apache/lucene/commit/fe6c3dc9397b0397aebf84fedb57875beb163d1d#diff-cd03a8db5d3607ff62811dcb2f8a8b6cae90402664beda95a702132d99992c18)
 to remove the ability to re-obtain a lock using the same instance, and instead 
it only provides a method to close (dispose) the lock once you're done with it. 
In that version of Lucene, it seems like IDisposable is the correct choice. I 
wish we could mark all these other methods as Obsolete, but unfortunately 
Obtain et al. are how it is intended to be used today, so we should not be 
throwing warnings upon use, even though the methods will be removed in a future 
version of Lucene.NET.
   
   In 4.8, it certainly does seem like this type is designed to be reusable, as 
you could theoretically obtain the lock when you need it, `close()` it to 
release it, and re-obtain it to do something else. This indicates that we 
should update Lock to use the new `ICloseable` interface once #271 is merged. 
To encourage best practices and compatibility with future Lucene.NET, we should 
leave this as IDisposable where Dispose calls Close, but provide this 
additional interface to allow for reuse. To avoid this being a breaking change, 
we should not throw if Dispose is called more than once, nor make it a no-op in 
that case. It can simply delegate the call to Close. 
   
   If possible, we should create an analyzer that looks for calls to any Lock 
methods after Dispose is called, and warn against such use.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to