Skip to content

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

@jhoeller

Description

@jhoeller

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.

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions