Skip to content

MongoClientFactorySupport overrides existing uuidRepresentation with MongoProperties default value #22321

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
christophstrobl opened this issue Jul 14, 2020 · 5 comments
Assignees
Labels
type: bug A general bug
Milestone

Comments

@christophstrobl
Copy link
Member

Original Bug Report: DATAMONGO-2561

I have MongoClientSettings bean defined in my configuration with STANTARD uuid representation.
After migration to spring 2.3.0 this value is always overridden by MongoProperties.uuidRepresentation.
MongoProperties.uuidRepresentation is a field with default value JAVA_LEGACY and even when spring.data.mongodb.uuidRepresentation property is not defined, the default value is used instead of one defined in MongoClientSettings.

MongoClientFactorySupport should check if the source MongoClientSettings passed to createClient already define an uuidRepresentation other than UNDEFINED before applying the default value from MongoProperties that then potentially overrides existing settings.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jul 14, 2020
@snicoll
Copy link
Member

snicoll commented Jul 14, 2020

Thanks for the report. Things have changed quite a lot in 2.3.x. In 2.2.x we had a MongoClientOptions with a bunch of settings that could be set by the user. If it was, the auto-configuration would take it and leave it untouched.

With the change of API, this turned into a MongoClientSettings. I can see that if that bean is set, the auto-configuration mutates it which feels a bit wrong to me. It does it because the scope of that object goes beyond what MongoClientOptions used to do. It basically encompasses all settings that the MongoClient needs.

For consistency, I think we should take that bean as is and not apply any properties customization to it when it is defined. Flagging for team attention to get some more feedback from the team.

@snicoll snicoll added for: team-attention An issue we'd like other members of the team to review type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Jul 14, 2020
@snicoll snicoll added this to the 2.3.x milestone Jul 14, 2020
@snicoll
Copy link
Member

snicoll commented Jul 14, 2020

Note that the 2.3.x behaviour I've described is not as new as I thought it would be. The reactive API has this MongoClientSettings and we do mutate it for reactive access in 2.2.x too.

@wilkinsona
Copy link
Member

For consistency, I think we should take that bean as is and not apply any properties customization to it when it is defined.

The feels right to me. I do wonder how many people may be relying on the current behaviour though.

@snicoll snicoll changed the title MongoClientFactorySupport overrides existing uuidRepresentation with MongoProperties default value. MongoClientFactorySupport overrides existing uuidRepresentation with MongoProperties default value Jul 14, 2020
@snicoll
Copy link
Member

snicoll commented Jul 14, 2020

We could move all that processing to a public MongoClientSettingsBuilderCustomizer. Users relying on that behaviour could apply this processing themselves when creating a custom MongoClientSettings.

I wonder if fixing this for 2.3.x only would be in order.

@philwebb philwebb removed the for: team-attention An issue we'd like other members of the team to review label Jul 15, 2020
@scottfrederick scottfrederick self-assigned this Aug 6, 2020
@scottfrederick scottfrederick added the for: team-attention An issue we'd like other members of the team to review label Aug 12, 2020
@philwebb philwebb modified the milestones: 2.3.x, 2.4.x Aug 12, 2020
@philwebb philwebb removed the for: team-attention An issue we'd like other members of the team to review label Aug 12, 2020
@scottfrederick
Copy link
Contributor

scottfrederick commented Aug 12, 2020

After a team discussion, we've decided to leave this as-is for 2.3.x and make a change for 2.4.x.

With Boot 2.3.x, the work-around is for users to do all configuration of MongoClientSettings in a MongoClientSettingsBuilderCustomizer instead of contributing a MongoClientSettings bean. Customizers run after MongoProperties have been copied to the MongoClientSettings, so this will ensure that the desired configuration is applied.

For 2.4.x, we won't make any changes to a MongoClientSettings bean that is provided by the user.

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

6 participants