-
Notifications
You must be signed in to change notification settings - Fork 38.6k
Description
Stuart Gunter opened SPR-10034 and commented
When shutting down the ApplicationContext, beans that implement DisposableBean are automatically destroyed. However, not all libraries depend on Spring and instead rely on java.io.Closeable for proper cleanup.
It would be very useful if Spring also called the Closeable.close() method on any bean that implements it.
Is this viable, or would it conflict with other behaviour within the framework?
An example that highlighted this problem is the CouchbaseClient, which is constructed via a FactoryBean, which means the destroy-method cannot be specified on the bean created by the factory. This prevents the app context from shutting down correctly. With the above behaviour, CouchbaseClient could be modified to implement java.io.Closeable and be appropriately destroyed on application termination.
Affects: 3.2 RC1
Issue Links:
- Support 'destroy method inference' for @Bean methods [SPR-8751] #13393 Support 'destroy method inference' for
@Bean
methods - Clarify Bean destroyMethod documentation [SPR-16078] #20627 Clarify Bean destroyMethod documentation
Referenced from: commits 9c6aa3e