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

Jackson serializaition module uses global mutable variables #368

Open
caeus opened this issue Aug 19, 2022 · 3 comments
Open

Jackson serializaition module uses global mutable variables #368

caeus opened this issue Aug 19, 2022 · 3 comments

Comments

@caeus
Copy link

caeus commented Aug 19, 2022

It is known global mutable variables are the root of all evil.

Also, my project uses two different CodecRegistries, so it basically uses different serialization configurations, and the fact that the bson mapper used by kmongo is global, ruins adoption for me.
(https://github.com/Litote/kmongo/blob/master/kmongo-jackson-mapping/src/main/kotlin/org/litote/kmongo/util/KMongoConfiguration.kt)
Can we make this a class, instead of an global object?

@zigzago
Copy link
Member

zigzago commented Aug 20, 2022

The issue is that KMongo provides stateless methods like .json or .bson with no relation with MongoClient instance.

So allowing to provide different configurations for a same java runtime would be error prone.

What is the use case for which you need to use two different CodecRegistries at the same time ?

@caeus
Copy link
Author

caeus commented Aug 22, 2022

Moving out of legacy mongo stuff. We cannot just change it all... So we want to give support with the old CodecRegistry, but in use a new CodecRegistry in the new collections

@zigzago
Copy link
Member

zigzago commented Sep 7, 2022

In java driver, CodecRegistry can be Collection scoped, Database scoped or Client scoped. It should be doable to pass a configuration for each of this class.

If you "legacy stuff" is not powered by KMongo, you have the option to set manually an old CodecRegistry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants