Skip to content

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

@spring-projects-issues

Description

@spring-projects-issues

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

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions