Ignore nonexistent default-destroy-method in XML config

Prior to this commit, DisposableBeanAdapter attempted to invoke a
configured default-destroy-method on every bean, including beans that
do not declare the named destroy method, resulting in a
NullPointerException being thrown and logged at WARN level.

This commit addresses this by effectively ignoring any nonexistent
destroy method.

Closes gh-30301
This commit is contained in:
Sam Brannen 2023-04-07 13:58:49 +02:00
parent b5b115e52c
commit c811428512
1 changed files with 3 additions and 1 deletions

View File

@ -236,9 +236,11 @@ class DisposableBeanAdapter implements DisposableBean, Runnable, Serializable {
}
else if (this.destroyMethods != null) {
for (Method destroyMethod : this.destroyMethods) {
if (destroyMethod != null) {
invokeCustomDestroyMethod(destroyMethod);
}
}
}
else if (this.destroyMethodNames != null) {
for (String destroyMethodName: this.destroyMethodNames) {
Method destroyMethod = determineDestroyMethod(destroyMethodName);