-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Require explicit representation configuration for UUID
, BigDecimal
, and BigInteger
#5044
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
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Hyunsang Han <[email protected]>
Signed-off-by: Hyunsang Han <[email protected]>
UUID
, BigDecimal
, and BigInteger
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The way these changes manifest is that application startup always breaks if uuid/big decimal representations aren't configured. That isn't ideal as users that don't need these features are forced to make a configuration change.
It would be much more appropriate to check whether such types are used at all.
A utility that walks the MongoMappingContext
and introspects whether entities have a property that uses UUID
, BigDecimal
, or BigInteger
would be less invasive and more targeted. We clearly cannot capture uuid/big decimal usage that operates solely on Document
s (no entity usage) and in these cases, applications would only fail during runtime.
|
||
MongoClientSettings settings = builder.build(); | ||
|
||
if (settings.getUuidRepresentation() == null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We would break applications for users that do not use UUIDs.
@@ -375,6 +376,10 @@ ConverterConfiguration createConverterConfiguration() { | |||
svc.init(); | |||
} | |||
|
|||
if (bigDecimals == null) { | |||
throw new IllegalStateException("BigDecimal representation must be explicitly configured."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same breaking behavior as for UUIDs. We would also break applications for users that do not use big decimals.
return builder.build(); | ||
MongoClientSettings settings = builder.build(); | ||
|
||
if (settings.getUuidRepresentation() == null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above.
Remove implicit defaults for UUID, BigDecimal, and BigInteger representations to force explicit configuration.
MongoConfigurationSupport
: Require explicitUuidRepresentation
configuration inmongoClientSettings()
MongoClientFactoryBean
: Require explicitUuidRepresentation
configuration incomputeClientSetting()
MongoCustomConversions
: Require explicitBigDecimalRepresentation
configuration (covers both BigDecimal and BigInteger)Resolves: #5037