-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Closed
Description
Eduard Valiauka opened SPR-13922 and commented
I have the following classes (in a 3rd-party library):
public abstract class MyAbstractClass {
public abstract MyAbstractClass shutdown();
}
public class MyImplementation extends MyAbstractClass {
@Override
public MyImplementation shutdown() {
//doing smth here
}
}
When I define a MyImplementation bean, I want to use shutdown as a destroyMethod and get the following exception:
Caused by: org.springframework.beans.factory.support.BeanDefinitionValidationException: Couldn't find a unique destroy method on bean with name 'someName: Cannot resolve method 'shutdown' to a unique method. Attempted to resolve to overloaded method with the least number of parameters, but there were 2 candidates.
at org.springframework.beans.factory.support.DisposableBeanAdapter.determineDestroyMethod(DisposableBeanAdapter.java:304) ~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.beans.factory.support.DisposableBeanAdapter.<init>(DisposableBeanAdapter.java:123) ~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.registerDisposableBeanIfNecessary(AbstractBeanFactory.java:1635) ~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:586) ~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE]
... 42 common frames omitted
The thing is that in fact MyImplementation.class.getMethods() contains 2 shutdown methods. One of them is a real one, another is just a bridge method and can be easily filtered out.
In any case this error message looks very strange.
Affects: 4.2.4
Issue Links:
- Destroy callback cannot be disabled for AutoCloseable beans [SPR-13022] #17613 Destroy callback cannot be disabled for AutoCloseable beans
Metadata
Metadata
Assignees
Labels
type: bugA general bugA general bug