From 6a05b97df328b66a25ac97a0f25b3f0cff560c90 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Wed, 8 May 2019 16:39:23 +0200 Subject: [PATCH] Log identity hash for ApplicationContext for context cache hits/misses DefaultCacheAwareContextLoaderDelegate now logs the identity hash code for an application context instance that was stored in or retrieved from the context cache in the Spring TestContext Framework. Closes gh-22925 --- .../cache/DefaultCacheAwareContextLoaderDelegate.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spring-test/src/main/java/org/springframework/test/context/cache/DefaultCacheAwareContextLoaderDelegate.java b/spring-test/src/main/java/org/springframework/test/context/cache/DefaultCacheAwareContextLoaderDelegate.java index 8bf77204e9..133373dc7f 100644 --- a/spring-test/src/main/java/org/springframework/test/context/cache/DefaultCacheAwareContextLoaderDelegate.java +++ b/spring-test/src/main/java/org/springframework/test/context/cache/DefaultCacheAwareContextLoaderDelegate.java @@ -123,8 +123,8 @@ public class DefaultCacheAwareContextLoaderDelegate implements CacheAwareContext try { context = loadContextInternal(mergedContextConfiguration); if (logger.isDebugEnabled()) { - logger.debug(String.format("Storing ApplicationContext in cache under key [%s]", - mergedContextConfiguration)); + logger.debug(String.format("Storing ApplicationContext [%s] in cache under key [%s]", + System.identityHashCode(context), mergedContextConfiguration)); } this.contextCache.put(mergedContextConfiguration, context); } @@ -134,8 +134,8 @@ public class DefaultCacheAwareContextLoaderDelegate implements CacheAwareContext } else { if (logger.isDebugEnabled()) { - logger.debug(String.format("Retrieved ApplicationContext from cache with key [%s]", - mergedContextConfiguration)); + logger.debug(String.format("Retrieved ApplicationContext [%s] from cache with key [%s]", + System.identityHashCode(context), mergedContextConfiguration)); } }