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:
parent
b5b115e52c
commit
c811428512
|
@ -236,9 +236,11 @@ class DisposableBeanAdapter implements DisposableBean, Runnable, Serializable {
|
||||||
}
|
}
|
||||||
else if (this.destroyMethods != null) {
|
else if (this.destroyMethods != null) {
|
||||||
for (Method destroyMethod : this.destroyMethods) {
|
for (Method destroyMethod : this.destroyMethods) {
|
||||||
|
if (destroyMethod != null) {
|
||||||
invokeCustomDestroyMethod(destroyMethod);
|
invokeCustomDestroyMethod(destroyMethod);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if (this.destroyMethodNames != null) {
|
else if (this.destroyMethodNames != null) {
|
||||||
for (String destroyMethodName: this.destroyMethodNames) {
|
for (String destroyMethodName: this.destroyMethodNames) {
|
||||||
Method destroyMethod = determineDestroyMethod(destroyMethodName);
|
Method destroyMethod = determineDestroyMethod(destroyMethodName);
|
||||||
|
|
Loading…
Reference in New Issue