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

Clarify Bean destroyMethod documentation [SPR-16078] #20627

Closed
spring-issuemaster opened this issue Oct 16, 2017 · 1 comment

Comments

Projects
None yet
2 participants
@spring-issuemaster
Copy link
Collaborator

commented Oct 16, 2017

Cameron Steffen opened SPR-16078 and commented

This paragraph seems to imply that setting destroyMethod="" will not disable destroy method inference for DisposableBean, Closeable and AutoCloseable beans.

To disable destroy method inference for a particular @Bean, specify an empty string as the value, e.g. @Bean(destroyMethod=""). Note that the DisposableBean and the Closeable/AutoCloseable interfaces will nevertheless get detected and the corresponding destroy/close method invoked.


Reference URL: https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/context/annotation/Bean.html#destroyMethod--

Issue Links:

  • #14347 Infer "shutdown()" as destroy method for convenient EHCache setup using @Bean
  • #14668 Support bean disposal on ApplicationContext shutdown for Closeable beans

Referenced from: commits d1b5b5d, dff2c84

Backported to: 4.3.13

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Oct 16, 2017

Juergen Hoeller commented

That paragraph is indeed not entirely correct: We always honor the DisposableBean callback interface but consider Closeable / AutoCloseable as part of destroy method inference. As a consequence, destroyMethod="" only affects the latter but not DisposableBean.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.