-
Notifications
You must be signed in to change notification settings - Fork 641
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
Overhaul TokenStream ICloseable/IDisposable Patterns, #271 #1058
base: master
Are you sure you want to change the base?
Conversation
…lTokenStream reusable
I feel confident enough in this now that it is ready for review. This PR achieves the original goals of #271, of not only ensuring that the original issue is fixed, but that we have implemented a design that allows for TokenStreams to be "closed" in a reusable way (via this new Additionally, the code in BaseTokenStreamTestCase has been reviewed several times and is now much closer to the original implementation. I've left the try/finally calls, since they probably should have been in the original Java anyways, and it seems to possibly help cascading failures (although I haven't been able to reproduce those, possibly as a result of other previous fixes). With all tests passing reliably, this design change implemented, and all concerns addressed in the original issue, I think it's time to wrap this up and call this 5+ year old issue complete. |
Overhaul TokenStream ICloseable/IDisposable Patterns
Fixes #271
Description
This pull request focuses on refactoring the codebase by replacing the
Dispose
method with the newICloseable
interface'sClose
method in all provided TokenStream implementations to make them reusable. None of the implementations in our codebase need a non-reusable cleanup method, however, in discussion in #271, it was determined that there are possible use cases in which a custom TokenStream implementation might need to have their instance Disposed when the owning Analyzer (with stored values set by a ReuseStrategy) is disposed, so we have retained the IDisposable pattern as well. This PR also ensures that those values are disposed by way of DisposableThreadLocal and TokenStreamComponents disposing of their values.