Skip to content

Handle null BeanFactory in StateMachineHandlerCallHelper #425

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 12, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -100,6 +103,12 @@ public void afterPropertiesSet() throws Exception {

@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;
Expand Down