Skip to content

MappingMongoConverterParser registers duplicate bean definitions #4087

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

Closed
adamchendd opened this issue Jun 16, 2022 · 0 comments
Closed

MappingMongoConverterParser registers duplicate bean definitions #4087

adamchendd opened this issue Jun 16, 2022 · 0 comments
Assignees
Labels
type: bug A general bug

Comments

@adamchendd
Copy link

When I view the source code of MappingMongoConverterParser, I found duplicated bean injection, the source code is down here

RootBeanDefinition validatorDef = new RootBeanDefinition(
				"org.springframework.validation.beanvalidation.LocalValidatorFactoryBean");
validatorDef.setSource(source);
validatorDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
String validatorName = parserContext.getReaderContext().registerWithGeneratedName(validatorDef);
parserContext.registerBeanComponent(new BeanComponentDefinition(validatorDef, validatorName));

in line 5 it called method registerWithGeneratedName, this method contains method registerBeanDefinition, and this method return beanName of validatorDef, which is 'org.springframework.validation.beanvalidation.LocalValidatorFactoryBean#0'.

in line 6, the method registerBeanComponent also calles method registerBeanDefinition with the same beanName, in Spring 5, beanDefinition overriding is not allowed by default value of false. When I run my application, it always throws BeanDefinitionOverrideException. I'm so confused about using spring-data-mongodb, can anybody help me explain this?

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jun 16, 2022
@mp911de mp911de added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Jun 20, 2022
@mp911de mp911de self-assigned this Jun 20, 2022
@mp911de mp911de changed the title Confused about the class MappingMongoConverterParser, it always throws BeanDefinitionOverrideException MappingMongoConverterParser registers duplicate bean definitions Jun 28, 2022
@mp911de mp911de added this to the 3.3.6 (2021.1.6) milestone Jun 28, 2022
mp911de added a commit that referenced this issue Jun 28, 2022
We now ensure to not override `ValidatingMongoEventListener` and `LocalValidatorFactoryBean` bean definitions by avoiding duplicate registrations and checking whether a bean with the given name is already registered.

Closes #4087
mp911de added a commit that referenced this issue Jun 28, 2022
We now ensure to not override `ValidatingMongoEventListener` and `LocalValidatorFactoryBean` bean definitions by avoiding duplicate registrations and checking whether a bean with the given name is already registered.

Closes #4087
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

3 participants