Skip to content

Commit

Permalink
[HHH-5511] (Infinispan Region.destroy() impl should call cache.stop()…
Browse files Browse the repository at this point in the history
…) Fixed.

[HHH-5512] (JndiInfinispanRegionFactory shouldn't try to stop CacheManager) Fixed.

git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@20288 1b8cb986-b30d-0410-93ca-fae66ebed9b2
  • Loading branch information
galderz committed Aug 31, 2010
1 parent 8176661 commit 31037bd
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 12 deletions.
Expand Up @@ -86,6 +86,10 @@ private EmbeddedCacheManager locateCacheManager(String jndiNamespace, Properties
}
}
}
}
}

@Override
public void stop() {
// Do not attempt to stop a cache manager because it wasn't created by this region factory.
}
}
Expand Up @@ -150,7 +150,8 @@ public Map toMap() {

public void destroy() throws CacheException {
try {
cacheAdapter.clear();
cacheAdapter.stop();
// cacheAdapter.clear();
} finally {
cacheAdapter.removeListener(this);
}
Expand Down
Expand Up @@ -156,6 +156,11 @@ public interface CacheAdapter {
*/
void clear() throws CacheException;

/**
* Stops the cache.
*/
void stop();

/**
* Add listener to this cache.
*
Expand Down
Expand Up @@ -32,6 +32,8 @@
import org.infinispan.context.Flag;
import org.infinispan.remoting.rpc.RpcManager;
import org.infinispan.util.concurrent.TimeoutException;
import org.infinispan.util.logging.Log;
import org.infinispan.util.logging.LogFactory;

/**
* CacheAdapterImpl.
Expand All @@ -40,6 +42,7 @@
* @since 3.5
*/
public class CacheAdapterImpl implements CacheAdapter {
private static final Log log = LogFactory.getLog(CacheAdapterImpl.class);

private final Cache cache;

Expand Down Expand Up @@ -142,6 +145,12 @@ public void clear() throws CacheException {
}
}

public void stop() {
if (log.isTraceEnabled())
log.trace("Stop " + cache);
cache.stop();
}

private static boolean isClusteredInvalidation(Configuration.CacheMode cacheMode) {
return cacheMode == Configuration.CacheMode.INVALIDATION_ASYNC
|| cacheMode == Configuration.CacheMode.INVALIDATION_SYNC;
Expand Down
Expand Up @@ -151,11 +151,6 @@ protected void tearDown() throws Exception {

super.tearDown();

if (localCollectionRegion != null)
localCollectionRegion.destroy();
if (remoteCollectionRegion != null)
remoteCollectionRegion.destroy();

try {
localCache.withFlags(FlagAdapter.CACHE_MODE_LOCAL).clear();
} catch (Exception e) {
Expand Down
Expand Up @@ -138,11 +138,6 @@ protected void tearDown() throws Exception {

super.tearDown();

if (localEntityRegion != null)
localEntityRegion.destroy();
if (remoteEntityRegion != null)
remoteEntityRegion.destroy();

try {
localCache.withFlags(FlagAdapter.CACHE_MODE_LOCAL).clear();
} catch (Exception e) {
Expand Down

0 comments on commit 31037bd

Please sign in to comment.