Handle null BeanFactory in StateMachineHandlerCallHelper

- Makes things less chatty if BeanFactory is null in
  StateMachineHandlerCallHelper as this is usually a case
  with manual builders outside of app context.
- Backport #412
- Relates #307
This commit is contained in:
Janne Valkealahti
2017-11-12 11:44:18 +00:00
parent 10ed7feeae
commit c2db915306

View File

@@ -72,6 +72,9 @@ public class StateMachineHandlerCallHelper<S, E> implements InitializingBean, Be
@SuppressWarnings("unchecked")
@Override
public void afterPropertiesSet() throws Exception {
if (beanFactory == null) {
return;
}
if (!(beanFactory instanceof ListableBeanFactory)) {
log.info("Beanfactory is not instance of ListableBeanFactory, was " + beanFactory + " thus Disabling handlers.");
return;
@@ -100,6 +103,12 @@ public class StateMachineHandlerCallHelper<S, E> implements InitializingBean, Be
@Override
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
if (beanFactory == null) {
// just skip if beanFactory is null as outside of spring
// app context, we usually don't have any factory features.
// in a same way further things will be skipped in afterPropertiesSet()
return;
}
Assert.state(beanFactory instanceof ListableBeanFactory,
"Bean factory must be instance of ListableBeanFactory, was " + beanFactory);
this.beanFactory = (ListableBeanFactory)beanFactory;