Browse Source

Revise "Ignore nonexistent default-destroy-method in XML config"

This commit revises the fix in c811428512.

Closes gh-30301
pull/30308/head
Sam Brannen 2 years ago
parent
commit
b23cc01cb7
  1. 10
      spring-beans/src/main/java/org/springframework/beans/factory/support/DisposableBeanAdapter.java

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

@ -115,7 +115,7 @@ class DisposableBeanAdapter implements DisposableBean, Runnable, Serializable { @@ -115,7 +115,7 @@ class DisposableBeanAdapter implements DisposableBean, Runnable, Serializable {
(bean instanceof AutoCloseable && CLOSE_METHOD_NAME.equals(destroyMethodNames[0]));
if (!this.invokeAutoCloseable) {
this.destroyMethodNames = destroyMethodNames;
Method[] destroyMethods = new Method[destroyMethodNames.length];
List<Method> destroyMethods = new ArrayList<>(destroyMethodNames.length);
for (int i = 0; i < destroyMethodNames.length; i++) {
String destroyMethodName = destroyMethodNames[i];
Method destroyMethod = determineDestroyMethod(destroyMethodName);
@ -138,10 +138,10 @@ class DisposableBeanAdapter implements DisposableBean, Runnable, Serializable { @@ -138,10 +138,10 @@ class DisposableBeanAdapter implements DisposableBean, Runnable, Serializable {
}
}
destroyMethod = ClassUtils.getInterfaceMethodIfPossible(destroyMethod, bean.getClass());
destroyMethods.add(destroyMethod);
}
destroyMethods[i] = destroyMethod;
}
this.destroyMethods = destroyMethods;
this.destroyMethods = destroyMethods.toArray(Method[]::new);
}
}
@ -236,9 +236,7 @@ class DisposableBeanAdapter implements DisposableBean, Runnable, Serializable { @@ -236,9 +236,7 @@ class DisposableBeanAdapter implements DisposableBean, Runnable, Serializable {
}
else if (this.destroyMethods != null) {
for (Method destroyMethod : this.destroyMethods) {
if (destroyMethod != null) {
invokeCustomDestroyMethod(destroyMethod);
}
invokeCustomDestroyMethod(destroyMethod);
}
}
else if (this.destroyMethodNames != null) {

Loading…
Cancel
Save