Skip to content

Commit 977550f

Browse files
committed
Properly handle null bean instance in getLifecycleBeans
Issue: SPR-16343
1 parent 18d90ec commit 977550f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

spring-context/src/main/java/org/springframework/context/support/DefaultLifecycleProcessor.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2017 the original author or authors.
2+
* Copyright 2002-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -285,9 +285,9 @@ protected Map<String, Lifecycle> getLifecycleBeans() {
285285
if ((getBeanFactory().containsSingleton(beanNameToRegister) &&
286286
(!isFactoryBean || matchesBeanType(Lifecycle.class, beanNameToCheck))) ||
287287
matchesBeanType(SmartLifecycle.class, beanNameToCheck)) {
288-
Lifecycle bean = getBeanFactory().getBean(beanNameToCheck, Lifecycle.class);
289-
if (bean != this) {
290-
beans.put(beanNameToRegister, bean);
288+
Object bean = getBeanFactory().getBean(beanNameToCheck);
289+
if (bean != this && bean instanceof Lifecycle) {
290+
beans.put(beanNameToRegister, (Lifecycle) bean);
291291
}
292292
}
293293
}

0 commit comments

Comments
 (0)