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

Invoke bean-derived (Auto)Closeable.close() method directly #27504

Closed
jhoeller opened this issue Oct 1, 2021 · 0 comments
Closed

Invoke bean-derived (Auto)Closeable.close() method directly #27504

jhoeller opened this issue Oct 1, 2021 · 0 comments
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Milestone

Comments

@jhoeller
Copy link
Contributor

jhoeller commented Oct 1, 2021

DisposableBeanAdapter historically calls everything other than DisposableBean.destroy() via reflection, including a close() method derived from the standard Closeable/AutoCloseable interface. This is partly due to AutoCloseable being Java 7+ and therefore only reflectively available on the Spring Framework 4.x baseline, partly also due to such a close() invocation being suppressible by the user through specifying an empty destroy method name. While the latter effect is worth preserving, the former can be replaced with a direct invocation after an AutoCloseable cast now. In addition to being more efficient on the JVM, this also avoids reflection metadata having to be available in a GraalVM native image just for that purpose.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

1 participant