-
Notifications
You must be signed in to change notification settings - Fork 133
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
Better handling of closeables in BasePolarisCatalog #478
Conversation
this.closeableGroup = CallContext.getCurrentContext().closeables(); | ||
closeableGroup.addCloseable(metricsReporter()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where do these get closed now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When BasePolarisCatalog.close()
is called.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I think that was my confusion. It looks like there are some objects in the CloseableGroup (the value ofmetricReporter()
) that are no longer going in there. I just wanted to double-check where they are getting closed now. Does putting this
in the CloseableGroup
somehow still do that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops you are right, I removed one line accidentally 🤦♂️ Thanks for spotting that, fixing.
bbcf373
to
4877fc3
Compare
Even if closeables are collected by `CallContext` and closed when the request finishes, it is safer to close the catalog's own cloaseables when `BasePolarisCatalog.close()` is called: this makes it possible to release resources when a test manually creates a catalog, or when the catalog is wrapped within `PolarisCatalogHandlerWrapper`. Furthermore, the "request" catalog used by PolarisCatalogHandlerWrapper is stored in `CallContext` under a different key, and closed manually in `PolarisApplication`: it is better to add the catalog to the `CallContext`'s closeables group and have it closed automatically when the `CallContext` is closed.
4877fc3
to
d10951d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Even if closeables are collected by
CallContext
and closed when the request finishes, it is safer to close the catalog's own cloaseables whenBasePolarisCatalog.close()
is called: this makes it possible to release resources when a test manually creates a catalog, or when the catalog is wrapped withinPolarisCatalogHandlerWrapper
.Furthermore, the "request" catalog used by PolarisCatalogHandlerWrapper is stored in
CallContext
under a different key, and closed manually inPolarisApplication
: it is better to add the catalog to theCallContext
's closeables group and have it closed automatically when theCallContext
is closed.