-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Ensure that all AutoCloseable binders are closed #42388
Conversation
Fixes: #422335
/cc @brunobat (micrometer), @ebullient (micrometer) |
Status for workflow
|
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.
I added a thought but feel free to ignore and merge :).
Thanks for tracking this!
new JvmGcMetrics().bindTo(Metrics.globalRegistry); | ||
JvmGcMetrics jvmGcMetrics = new JvmGcMetrics(); | ||
jvmGcMetrics.bindTo(Metrics.globalRegistry); | ||
autoCloseables.add(jvmGcMetrics); |
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.
I wonder if I would add all the listeners to a List and then close them if they are Closeable or AutoCloseable. That might be more future proof.
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.
I understand where the desire for defensiveness against such OOMs is coming from, but in this case, I think it's overkill.
In reality, this issue was being flagged by IntelliJ (as the auto-closable was never being closed), we just didn't pay attention - and we absolutely should next time :)
The OOM in the issue was caused by a class being help in a notification listener queue for JMX messages.
The fix is simply to remove close the binder that then removes the listener.