From 8874cadebf6781adde806fad3b3a402d2e00ea51 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Tue, 12 Sep 2023 08:19:47 +0100 Subject: [PATCH] Revert workaround for gh-18440 This reverts the main code changes from commit b240c810a810c873e84d058614b5d0174591cff9. The tests are kept to verify that the workaround is no longer required. Closes gh-18591 --- .../ConfigurationPropertiesBean.java | 29 +------------------ 1 file changed, 1 insertion(+), 28 deletions(-) diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/ConfigurationPropertiesBean.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/ConfigurationPropertiesBean.java index 186184b7c8..3fa38d8439 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/ConfigurationPropertiesBean.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/ConfigurationPropertiesBean.java @@ -23,7 +23,6 @@ import java.lang.reflect.Method; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.Map; -import java.util.concurrent.atomic.AtomicReference; import org.springframework.aop.support.AopUtils; import org.springframework.beans.factory.NoSuchBeanDefinitionException; @@ -42,8 +41,6 @@ import org.springframework.core.annotation.MergedAnnotation; import org.springframework.core.annotation.MergedAnnotations; import org.springframework.core.annotation.MergedAnnotations.SearchStrategy; import org.springframework.util.Assert; -import org.springframework.util.ClassUtils; -import org.springframework.util.ReflectionUtils; import org.springframework.validation.annotation.Validated; /** @@ -237,36 +234,12 @@ public final class ConfigurationPropertiesBean { if (beanFactory.containsBeanDefinition(beanName)) { BeanDefinition beanDefinition = beanFactory.getMergedBeanDefinition(beanName); if (beanDefinition instanceof RootBeanDefinition rootBeanDefinition) { - Method resolvedFactoryMethod = rootBeanDefinition.getResolvedFactoryMethod(); - if (resolvedFactoryMethod != null) { - return resolvedFactoryMethod; - } + return rootBeanDefinition.getResolvedFactoryMethod(); } - return findFactoryMethodUsingReflection(beanFactory, beanDefinition); } return null; } - private static Method findFactoryMethodUsingReflection(ConfigurableListableBeanFactory beanFactory, - BeanDefinition beanDefinition) { - String factoryMethodName = beanDefinition.getFactoryMethodName(); - String factoryBeanName = beanDefinition.getFactoryBeanName(); - if (factoryMethodName == null || factoryBeanName == null) { - return null; - } - Class factoryType = beanFactory.getType(factoryBeanName); - if (factoryType.getName().contains(ClassUtils.CGLIB_CLASS_SEPARATOR)) { - factoryType = factoryType.getSuperclass(); - } - AtomicReference factoryMethod = new AtomicReference<>(); - ReflectionUtils.doWithMethods(factoryType, (method) -> { - if (method.getName().equals(factoryMethodName)) { - factoryMethod.set(method); - } - }); - return factoryMethod.get(); - } - static ConfigurationPropertiesBean forValueObject(Class beanType, String beanName) { Bindable bindTarget = createBindTarget(null, beanType, null); Assert.state(bindTarget != null && deduceBindMethod(bindTarget) == VALUE_OBJECT_BIND_METHOD,