From bc7a31c661216e099633d97dbf3baa0db5d067c1 Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Fri, 10 Jul 2009 23:29:36 +0000 Subject: [PATCH] When we shutdown our EHCacheAdapter, go through and flush everything from memory so that if we turn around and recreate a PersistenceContext with a brand new classloader and start loading things from the cache, we don't have freakoutery because there's a record in memory that was resolved with the old classloader. Plus it allows those old classloaders to get collected. --- src/java/com/samskivert/depot/EHCacheAdapter.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/java/com/samskivert/depot/EHCacheAdapter.java b/src/java/com/samskivert/depot/EHCacheAdapter.java index ffebac2..b2ca126 100644 --- a/src/java/com/samskivert/depot/EHCacheAdapter.java +++ b/src/java/com/samskivert/depot/EHCacheAdapter.java @@ -140,6 +140,13 @@ public class EHCacheAdapter { log.debug("EHCacheAdapter shutting down", "lookups", _lookups, "stores", _stores, "removes", _removes, "enumerations", _enumerations); + + // go through and flush all of the caches we resolved + for (Ehcache cache : _categories.values()) { + cache.flush(); + } + _categories.clear(); + _bins.clear(); } /**