Skip to content

Commit c811428

Browse files
committed
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
1 parent b5b115e commit c811428

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

spring-beans/src/main/java/org/springframework/beans/factory/support/DisposableBeanAdapter.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,9 @@ public void destroy() {
236236
}
237237
else if (this.destroyMethods != null) {
238238
for (Method destroyMethod : this.destroyMethods) {
239-
invokeCustomDestroyMethod(destroyMethod);
239+
if (destroyMethod != null) {
240+
invokeCustomDestroyMethod(destroyMethod);
241+
}
240242
}
241243
}
242244
else if (this.destroyMethodNames != null) {

0 commit comments

Comments
 (0)