• Bug
  • Status: Resolved
  • 2 Major
  • Resolution: Won't Fix
  • ehcache-core
  • teck
  • Reporter: amiller
  • October 30, 2009
  • 0
  • Watchers: 2
  • August 21, 2013
  • August 21, 2013


The shutdown hook code looks like it could be cleaned up a bit. There is a synchronized(this) that occurs on the shutdown hook thread and serves no purpose here:

        Thread localShutdownHook = new Thread() {
            public void run() {
                synchronized (this) {
                    if (status.equals(Status.STATUS_ALIVE)) {
                        // clear shutdown hook reference to prevent
                        // removeShutdownHook to remove it during shutdown
                        shutdownHook = null;

                        if (LOG.isLoggable(Level.INFO)) {
                            LOG.log(Level.INFO, "VM shutting down with the CacheManager still active. Calling shutdown.");

It also seems like the removal of the shutdown hook to prevent memory leaks could be handled by not using an inner class and possibly using a WeakReference back to the CacheManager.


Tim Eck 2009-10-30

perhaps that logic is better suited for a synchronized method back on the enclosing cachemanager instance?

Fiona OShea 2010-08-11

Is this still even an issue?

Tim Eck 2010-08-12

the particular synchronization mentioned is stupid and serves no purpose (other than to confuse the reader). Beyond that it doesn’t hurt.

I don’t have any particular motivation to take up the task of replacing this shutdown hook with something based on weak references