ninjaframework / ninja-ebean

Ebean ORM support for Ninja Framework
Apache License 2.0
10 stars 8 forks source link

NinjaEbeanDatabaseLifecycle- Shutdown Manager #18

Open hugogoncalves opened 2 years ago

hugogoncalves commented 2 years ago

Why has been changed the ShutdownManager from touch to shutdown?

// Activate the Ebean shutdown manager (disconnects from db, shuts down all threads and so on) ShutdownManager.shutdown(); } I had some issues with L2 caches, complains of Not able to notify caches. All complains were about tasks beiing rejected by ThreadPool from DefaultBackgroundExecutor. I changed that line to ShutdownManager.touch and my issues disapeared.

h-arlt commented 1 year ago

I totally agree with the author; calling ShutdownManager.shutdown() doesn't make any sense to me either.

What about to register the database at Ebean's ShutdownManager instead?

        // Register database at Ebean's shutdown manager (disconnects from db, shuts down all threads and so on)
        ShutdownManager.registerDatabase(ebeanDatabase);

AFAIK, ShutdownManager.touch is a no-op. As side-effect of loading this class its shutdown hook is registered at JVM but as long as it doesn't have any knowledge about the database created a few lines above, the shutdown hook won't shut the database down.