You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In what version(s) of Spring Integration are you seeing this issue?
Since 6.4
Describe the bug
The ControlBusCommandRegistry implements DestructionAwareBeanPostProcessor but does not override requiresDestruction, which defaults to true. As a result, beans that are not meant to be processed during the destroy lifecycle are being registered for the procedure (AbstractBeanFactory#registerDisposableBeanIfNecessary). We are receiving loads of SimpleThreadScope does not support destruction callbacks.Consider using RequestScope in a web environment. logs.
Yeah... I thought that check is per DestructionAwareBeanPostProcessor , but apparently that is for the whole BeanFactory:
/**
* Check whether the given bean has destruction-aware post-processors applying to it.
* @param bean the bean instance
* @param postProcessors the post-processor candidates
*/
public static boolean hasApplicableProcessors(Object bean, List<DestructionAwareBeanPostProcessor> postProcessors) {
if (!CollectionUtils.isEmpty(postProcessors)) {
for (DestructionAwareBeanPostProcessor processor : postProcessors) {
if (processor.requiresDestruction(bean)) {
return true;
}
}
}
return false;
}
So, yes, the ControlBusCommandRegistry has to implement this requiresDestruction() to return true only for those beans processes by this registry.
Fixes: #9890
Issue link: #9890
The `DestructionAwareBeanPostProcessor.requiresDestruction()` defaults to `true`.
As a result, beans that are not meant to be processed during the destroy lifecycle
are being registered for the `AbstractBeanFactory#registerDisposableBeanIfNecessary`.
for example, the `SimpleThreadScope` does not support destruction callbacks.
In other words, the `DestructionAwareBeanPostProcessor.requiresDestruction()` contract
is not merely for `DestructionAwareBeanPostProcessor` logic, but also has an effect
on the whole `BeanFactory`
* Implement `requiresDestruction()` in the `ControlBusCommandRegistry`
for same filter as `registerControlBusCommands()` does right now.
* Optimize behaviour using `MergedAnnotations` for the class instead of
`AnnotationUtils.findAnnotation()` twice, which creates the mentioned `MergedAnnotations` internally.
(cherry picked from commit 74cf59b)
In what version(s) of Spring Integration are you seeing this issue?
Since 6.4
Describe the bug
The
ControlBusCommandRegistry
implementsDestructionAwareBeanPostProcessor
but does not overriderequiresDestruction
, which defaults to true. As a result, beans that are not meant to be processed during the destroy lifecycle are being registered for the procedure (AbstractBeanFactory#registerDisposableBeanIfNecessary). We are receiving loads ofSimpleThreadScope does not support destruction callbacks.Consider using RequestScope in a web environment.
logs.To Reproduce
Run the tests in https://github.com/t-ondrej/control-bus-command-registry-bug repo
Expected behavior
The
ControlBusCommandRegistry
implementsrequiresDestruction
with proper post processing eligibility check.The text was updated successfully, but these errors were encountered: