diff --git a/spring-context-support/src/main/java/org/springframework/cache/guava/GuavaCacheManager.java b/spring-context-support/src/main/java/org/springframework/cache/guava/GuavaCacheManager.java
index 2f83f5567b2..26092ee3ead 100644
--- a/spring-context-support/src/main/java/org/springframework/cache/guava/GuavaCacheManager.java
+++ b/spring-context-support/src/main/java/org/springframework/cache/guava/GuavaCacheManager.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2013 the original author or authors.
+ * Copyright 2002-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,6 +19,7 @@ package org.springframework.cache.guava;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
+import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
@@ -29,6 +30,7 @@ import com.google.common.cache.CacheLoader;
import org.springframework.cache.Cache;
import org.springframework.cache.CacheManager;
import org.springframework.util.Assert;
+import org.springframework.util.ObjectUtils;
/**
* {@link CacheManager} implementation that lazily builds {@link GuavaCache}
@@ -45,6 +47,7 @@ import org.springframework.util.Assert;
*
Requires Google Guava 12.0 or higher.
*
* @author Juergen Hoeller
+ * @author Stephane Nicoll
* @since 4.0
* @see GuavaCache
*/
@@ -81,6 +84,8 @@ public class GuavaCacheManager implements CacheManager {
* Specify the set of cache names for this CacheManager's 'static' mode.
*
The number of caches and their names will be fixed after a call to this method,
* with no creation of further cache regions at runtime.
+ *
Calling this with a {@code null} collection argument resets the
+ * mode to 'dynamic', allowing for further creation of caches again.
*/
public void setCacheNames(Collection cacheNames) {
if (cacheNames != null) {
@@ -89,6 +94,9 @@ public class GuavaCacheManager implements CacheManager {
}
this.dynamic = false;
}
+ else {
+ this.dynamic = true;
+ }
}
/**
@@ -99,7 +107,7 @@ public class GuavaCacheManager implements CacheManager {
*/
public void setCacheBuilder(CacheBuilder