codeconsole opened a new pull request, #15743: URL: https://github.com/apache/grails-core/pull/15743
## What GORM's connection-source shutdown closes any `Closeable` source, and `com.mongodb.client.MongoClient` is `Closeable`, so a client handed to GORM — a Spring-managed bean, or one passed to `new MongoDatastore(mongoClient, ...)` — was closed when the datastore shut down. That double-closes a client whose lifecycle is owned elsewhere. This makes GORM **not close a `MongoClient` it did not create**: - `DefaultConnectionSource` gains a non-closeable mode (new 4-arg constructor + `isCloseable()`); the existing constructor is unchanged, so there is no behavior change for current callers. - `MongoDatastore.createDefaultConnectionSources` wraps an externally-supplied client as non-closeable. - `MongoDbGormAutoConfiguration` implements `DisposableBean` and closes only the client it created itself; a client supplied as a bean is left for the application context to close. GORM still closes clients it creates from `grails.mongodb.*` configuration. ## Why - Removes a redundant double-close in the common Spring Boot setup (Spring already owns and closes the `MongoClient` bean). - Establishes "whoever creates the client owns closing it" — the safe basis for sharing one `MongoClient` across GORM and other consumers. ## Behavior change The only externally-visible change: callers that relied on `MongoDatastore.close()` to also close a client they passed in must now close it themselves. Documented in the upgrade notes. ## Tests - `DefaultConnectionSourceSpec` — closes by default; no-op when non-closeable; closes an `AutoCloseable` when closeable. - `MongoDatastoreExternalClientSpec` — a supplied client is not closed on datastore shutdown. - `MongoDbGormAutoConfigurationCloseSpec` — the auto-config closes only an internally-created client. Targets `8.0.x`. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
