Prior to this commit, NettyDriverMongoClientSettingsBuilderCustomizer could create more than one instance of NioEventLoopGroup in case if it has been invoked for several MongoClientSettings, but the reference was only to the last instance, hence shutdown was invoked only for the last NioEventLoopGroup.
see gh-17533
Comment From: wilkinsona
Thanks, @nosan. I'm not sure what direction we want to take with this one just yet. Two things in particular with your proposal that I'm not sure about:
- The event loop group will now always be created even if it isn't used
- The event loop group will be shared across multiple clients
@mp911de what's your take on #17533 and the fix proposed here please?
Comment From: nosan
Thanks, @wilkinsona
The event loop group will now always be created even if it isn't used
Unfortunately yes ( by default, 0 threads)
The event loop group will be shared across multiple clients
I'm not sure that could be an issue.
As an alternative approach,List<NioEventLoopGroup can be used.
Comment From: mp911de
- The event loop group will now always be created even if it isn't used
We should do something about that.
- The event loop group will be shared across multiple clients
This is actually a good effect. We should ideally keep only a single EventLoopGroup around to not waste system resources. See my comment in #17533.
Comment From: wilkinsona
This is actually a good effect. We should ideally keep only a single EventLoopGroup around to not waste system resources. See my comment in #17533.
Thank you, @mp911de. That's what I suspected but wanted some expert confirmation.
Let's see where the discussion on #17533 leads.
Comment From: bclozel
I'm closing this PR as I don't think that shared resources like this should be managed by the auto-configuration itself. Just like we have a ReactorResourceFactory now in Spring Framework, I believe they should be bound to the context lifecycle with a component in the first place.
I'll add more about that in a comment in #17533
Thanks @nosan for your help!