Invoke bean-derived (Auto)Closeable.close() method directly #27504
Labels
in: core
Issues in core modules (aop, beans, core, context, expression)
type: enhancement
A general enhancement
Milestone
DisposableBeanAdapter
historically calls everything other thanDisposableBean.destroy()
via reflection, including aclose()
method derived from the standardCloseable
/AutoCloseable
interface. This is partly due toAutoCloseable
being Java 7+ and therefore only reflectively available on the Spring Framework 4.x baseline, partly also due to such aclose()
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 anAutoCloseable
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.The text was updated successfully, but these errors were encountered: