From 0fd4e40e6e3ab14c9670634d27a1594485a5bc4f Mon Sep 17 00:00:00 2001 From: Johnny Lim Date: Thu, 19 Jul 2018 11:45:40 +0900 Subject: [PATCH] Add null guards for getBeanDefinition() in BeanTypeRegistry Closes gh-13818 --- .../condition/BeanTypeRegistry.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/BeanTypeRegistry.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/BeanTypeRegistry.java index 799b039b0c..fdb6819bd4 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/BeanTypeRegistry.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/BeanTypeRegistry.java @@ -159,7 +159,10 @@ final class BeanTypeRegistry implements SmartInitializingSingleton { } private void addBeanTypeForNonAliasDefinition(String name) { - addBeanTypeForNonAliasDefinition(name, getBeanDefinition(name)); + RootBeanDefinition beanDefinition = getBeanDefinition(name); + if (beanDefinition != null) { + addBeanTypeForNonAliasDefinition(name, beanDefinition); + } } private RootBeanDefinition getBeanDefinition(String name) { @@ -219,11 +222,13 @@ final class BeanTypeRegistry implements SmartInitializingSingleton { if (!this.beanFactory.isAlias(name) && !this.beanFactory.containsSingleton(name)) { RootBeanDefinition beanDefinition = getBeanDefinition(name); - RootBeanDefinition existingDefinition = this.beanDefinitions.put(name, - beanDefinition); - if (existingDefinition != null - && !beanDefinition.equals(existingDefinition)) { - addBeanTypeForNonAliasDefinition(name, beanDefinition); + if (beanDefinition != null) { + RootBeanDefinition existingDefinition = this.beanDefinitions + .put(name, beanDefinition); + if (existingDefinition != null + && !beanDefinition.equals(existingDefinition)) { + addBeanTypeForNonAliasDefinition(name, beanDefinition); + } } } }