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

DisposableBeanAdapter throws NPE for default-destroy-method [SPR-6211] #10879

Closed
spring-projects-issues opened this issue Oct 8, 2009 · 1 comment
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: bug A general bug
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

Mike Quilleash opened SPR-6211 and commented

I have a spring <beans> with default-destroy-method="destroy". Some of my beans have a destroy() method, some don't.

It looks like, inside the DisposableBeanAdapter the following happens for the beans that do NOT have a destroy() method.

  • Construction
  • destroyMethodName looked up from bean definition
  • destoryMethod looked up from name, gets null
  • validates that destroy method can be null (beanDefinition.isEnforceDestroyMethod())

Then on dispose

  • destroyMethod is null
  • destroyMethodName is not null, tries to look up destroyMethod again, and gets null again
  • passes result to invokeCustomDestroyMethod()
  • invokeCustomDestroyMethod() throws NPE as destroyMethod is null

Possible solution would be to null out destroyMethodName in the constructor if the method is not found, or perhaps not create the DisposableBeanAdapter at all.


Affects: 3.0 M4

Referenced from: commits 11d9870

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

Thanks for pointing this out! Fixed for RC2.

Juergen

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: bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants