1
1
/*
2
- * Copyright 2002-2018 the original author or authors.
2
+ * Copyright 2002-2019 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -112,15 +112,15 @@ public DisposableBeanAdapter(Object bean, String beanName, RootBeanDefinition be
112
112
if (destroyMethodName != null && !(this .invokeDisposableBean && "destroy" .equals (destroyMethodName )) &&
113
113
!beanDefinition .isExternallyManagedDestroyMethod (destroyMethodName )) {
114
114
this .destroyMethodName = destroyMethodName ;
115
- this . destroyMethod = determineDestroyMethod (destroyMethodName );
116
- if (this . destroyMethod == null ) {
115
+ Method destroyMethod = determineDestroyMethod (destroyMethodName );
116
+ if (destroyMethod == null ) {
117
117
if (beanDefinition .isEnforceDestroyMethod ()) {
118
118
throw new BeanDefinitionValidationException ("Could not find a destroy method named '" +
119
119
destroyMethodName + "' on bean with name '" + beanName + "'" );
120
120
}
121
121
}
122
122
else {
123
- Class <?>[] paramTypes = this . destroyMethod .getParameterTypes ();
123
+ Class <?>[] paramTypes = destroyMethod .getParameterTypes ();
124
124
if (paramTypes .length > 1 ) {
125
125
throw new BeanDefinitionValidationException ("Method '" + destroyMethodName + "' of bean '" +
126
126
beanName + "' has more than one parameter - not supported as destroy method" );
@@ -129,7 +129,9 @@ else if (paramTypes.length == 1 && boolean.class != paramTypes[0]) {
129
129
throw new BeanDefinitionValidationException ("Method '" + destroyMethodName + "' of bean '" +
130
130
beanName + "' has a non-boolean parameter - not supported as destroy method" );
131
131
}
132
+ destroyMethod = ClassUtils .getInterfaceMethodIfPossible (destroyMethod );
132
133
}
134
+ this .destroyMethod = destroyMethod ;
133
135
}
134
136
this .beanPostProcessors = filterPostProcessors (postProcessors , bean );
135
137
}
@@ -271,9 +273,9 @@ public void destroy() {
271
273
invokeCustomDestroyMethod (this .destroyMethod );
272
274
}
273
275
else if (this .destroyMethodName != null ) {
274
- Method methodToCall = determineDestroyMethod (this .destroyMethodName );
275
- if (methodToCall != null ) {
276
- invokeCustomDestroyMethod (methodToCall );
276
+ Method methodToInvoke = determineDestroyMethod (this .destroyMethodName );
277
+ if (methodToInvoke != null ) {
278
+ invokeCustomDestroyMethod (ClassUtils . getInterfaceMethodIfPossible ( methodToInvoke ) );
277
279
}
278
280
}
279
281
}
0 commit comments