21
21
import java .util .List ;
22
22
import java .util .Map ;
23
23
import java .util .Set ;
24
+ import java .util .concurrent .ConcurrentHashMap ;
24
25
import java .util .concurrent .atomic .AtomicInteger ;
25
26
26
27
import org .apache .commons .logging .Log ;
27
28
import org .apache .commons .logging .LogFactory ;
29
+
28
30
import org .springframework .context .ApplicationContext ;
29
31
import org .springframework .context .ConfigurableApplicationContext ;
30
32
import org .springframework .core .style .ToStringCreator ;
31
33
import org .springframework .test .annotation .DirtiesContext .HierarchyMode ;
32
34
import org .springframework .test .context .ContextCache ;
33
35
import org .springframework .test .context .MergedContextConfiguration ;
34
36
import org .springframework .util .Assert ;
35
- import org .springframework .util .ConcurrentReferenceHashMap ;
36
37
37
38
/**
38
39
* Default implementation of the {@link ContextCache} API.
39
40
*
40
- * <p>Uses Spring's {@link ConcurrentReferenceHashMap} to store
41
- * {@linkplain java.lang.ref.SoftReference soft references} to cached
42
- * contexts and {@code MergedContextConfiguration} instances.
41
+ * <p>Uses {@link ConcurrentHashMap ConcurrentHashMaps} to cache
42
+ * {@link ApplicationContext} and {@link MergedContextConfiguration} instances.
43
43
*
44
44
* @author Sam Brannen
45
45
* @author Juergen Hoeller
46
46
* @since 2.5
47
- * @see ConcurrentReferenceHashMap
48
47
*/
49
48
public class DefaultContextCache implements ContextCache {
50
49
@@ -54,7 +53,7 @@ public class DefaultContextCache implements ContextCache {
54
53
* Map of context keys to Spring {@code ApplicationContext} instances.
55
54
*/
56
55
private final Map <MergedContextConfiguration , ApplicationContext > contextMap =
57
- new ConcurrentReferenceHashMap <MergedContextConfiguration , ApplicationContext >(64 );
56
+ new ConcurrentHashMap <MergedContextConfiguration , ApplicationContext >(64 );
58
57
59
58
/**
60
59
* Map of parent keys to sets of children keys, representing a top-down <em>tree</em>
@@ -63,7 +62,7 @@ public class DefaultContextCache implements ContextCache {
63
62
* of other contexts.
64
63
*/
65
64
private final Map <MergedContextConfiguration , Set <MergedContextConfiguration >> hierarchyMap =
66
- new ConcurrentReferenceHashMap <MergedContextConfiguration , Set <MergedContextConfiguration >>(64 );
65
+ new ConcurrentHashMap <MergedContextConfiguration , Set <MergedContextConfiguration >>(64 );
67
66
68
67
private final AtomicInteger hitCount = new AtomicInteger ();
69
68
0 commit comments