You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using simple application with spring boot web app and spring-data-mongodb connected to MongoDB cluster with multiple nodes SpringApplication.exit(...) is usually not closing application due to locks (for example - GC execution is releasing lock).
Sample application:
@SpringBootApplication
public class SpringDataMongodbSSL {
public static void main(String[] args) {
SpringApplication.run(SpringDataMongodbSSL.class, args);
}
@EventListener(ApplicationReadyEvent.class)
public void close(ApplicationReadyEvent event) {
Timer timer = new Timer();
timer.schedule(new TimerTask() {
@Override
public void run() {
System.out.println("Closing context");
SpringApplication.exit(event.getApplicationContext(), () -> 0);
System.out.println("Context closed");
}
}, 15 * 1000);
}
}
Configuration on application.yml contain only mongo uri and server.shutdown=graceful to print shutdown on the console (behavior the same without this property).
Execution logs:
Discovered replica set primary DB_URL:27017 with max election id 7fffffff0000000000000026 and max set
Closing context
Commencing graceful shutdown. Waiting for active requests to complete
Graceful shutdown complete
Context closed
And then application is still running.
Profiling results:
Repository with example: Repository
Spring Boot: 3.3.0
Java: 21
The text was updated successfully, but these errors were encountered:
Uh oh!
There was an error while loading. Please reload this page.
When using simple application with spring boot web app and spring-data-mongodb connected to MongoDB cluster with multiple nodes SpringApplication.exit(...) is usually not closing application due to locks (for example - GC execution is releasing lock).
Sample application:
Configuration on application.yml contain only mongo uri and server.shutdown=graceful to print shutdown on the console (behavior the same without this property).
Execution logs:
And then application is still running.
Profiling results:

Repository with example: Repository
Spring Boot: 3.3.0
Java: 21
The text was updated successfully, but these errors were encountered: