GH-780 Fix lifecycle of Kotlin function transformation

Resolves #780
This commit is contained in:
Oleg Zhurakousky
2021-12-07 13:23:07 +01:00
parent 95cae89392
commit cdae21b616

View File

@@ -37,9 +37,9 @@ import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.SmartInitializingSingleton;
import org.springframework.beans.factory.annotation.AnnotatedBeanDefinition;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.config.ConstructorArgumentValues;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
@@ -74,11 +74,12 @@ public class KotlinLambdaToFunctionAutoConfiguration {
* @return the bean factory post processor
*/
@Bean
public SmartInitializingSingleton kotlinToFunctionTransformer(ConfigurableListableBeanFactory beanFactory) {
return new SmartInitializingSingleton() {
public static BeanFactoryPostProcessor kotlinToFunctionTransformer(ConfigurableListableBeanFactory beanFactory) {
return new BeanFactoryPostProcessor() {
@Override
public void afterSingletonsInstantiated() {
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory)
throws BeansException {
String[] beanDefinitionNames = beanFactory.getBeanDefinitionNames();
for (String beanDefinitionName : beanDefinitionNames) {
BeanDefinition beanDefinition = beanFactory.getBeanDefinition(beanDefinitionName);
@@ -95,11 +96,9 @@ public class KotlinLambdaToFunctionAutoConfiguration {
}
}
}
};
}
@SuppressWarnings({ "unchecked", "rawtypes" })
public static final class KotlinFunctionWrapper implements Function<Object, Object>, Supplier<Object>, Consumer<Object>,
Function0<Object>, Function1<Object, Object>, Function2<Object, Object, Object>,