Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Lucene.Net.Store.Lock reusable #1073

Open
1 task done
paulirwin opened this issue Dec 21, 2024 · 0 comments
Open
1 task done

Make Lucene.Net.Store.Lock reusable #1073

paulirwin opened this issue Dec 21, 2024 · 0 comments
Labels
is:enhancement New feature or request is:task A chore to be done

Comments

@paulirwin
Copy link
Contributor

paulirwin commented Dec 21, 2024

Is there an existing issue for this?

  • 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 Lucene 5.3.0, the Lock API was simplified 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.

@paulirwin paulirwin added is:enhancement New feature or request is:task A chore to be done labels Dec 21, 2024
@paulirwin paulirwin added this to the 4.8.0-beta00018 milestone Dec 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
is:enhancement New feature or request is:task A chore to be done
Projects
None yet
Development

No branches or pull requests

1 participant