Skip to content
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

When registerSingleton of BeanPostProcessor or BeanFactoryPostProcessor, SofaModuleBeanFactoryPostProcessor will cause app startup fail #213

Closed
straybirdzls opened this issue Sep 13, 2018 · 1 comment
Assignees
Labels
bug Something isn't working
Milestone

Comments

@straybirdzls
Copy link
Member

In com.alipay.sofa.isle.spring.listener.SofaModuleBeanFactoryPostProcessor

 public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory)
                                                                                   throws BeansException {
        Map<String, BeanDefinition> postProcessorDefinitions = getBeanDefinitionsForType(
            beanFactory, BeanPostProcessor.class, BeanFactoryPostProcessor.class);
        beanFactory.registerSingleton(
            SofaModuleFrameworkConstants.PROCESSORS_OF_ROOT_APPLICATION_CONTEXT,
            postProcessorDefinitions);
    }

private Map<String, BeanDefinition> getBeanDefinitionsForType(ConfigurableListableBeanFactory beanFactory,
                                                                  Class... types) {
        Map<String, BeanDefinition> map = new HashMap<>();
        for (Class type : types) {
            String[] beanNamesForType = beanFactory.getBeanNamesForType(type);
            for (String beanName : beanNamesForType) {
                if (notInWhiteNameList(beanName)) {
                    map.put(beanName, beanFactory.getBeanDefinition(beanName));
                }
            }
        }

        return map;
    }

will cause application startup fail due to org.springframework.beans.factory.NoSuchBeanDefinitionException

@straybirdzls straybirdzls self-assigned this Sep 13, 2018
@straybirdzls straybirdzls added the bug Something isn't working label Sep 13, 2018
@straybirdzls straybirdzls added this to the 2.4.8 milestone Sep 13, 2018
@straybirdzls
Copy link
Member Author

attach example log: errorlog.txt

@straybirdzls straybirdzls changed the title When registerSingleton of BeanPostProcessor or BeanFactoryPostProcessor, SofaModuleBeanFactoryPostProcessor will cause app start fail When registerSingleton of BeanPostProcessor or BeanFactoryPostProcessor, SofaModuleBeanFactoryPostProcessor will cause app startup fail Sep 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants