From 262c702da4588e5f467fd24774357113379666b2 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Thu, 22 Nov 2018 11:20:47 +0100 Subject: [PATCH] CachingMetadataReaderFactory releases shared cache Map on clearCache() LocalResourceCache properly initializes cacheLimit on construction. Issue: SPR-17527 --- .../core/type/classreading/CachingMetadataReaderFactory.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/spring-core/src/main/java/org/springframework/core/type/classreading/CachingMetadataReaderFactory.java b/spring-core/src/main/java/org/springframework/core/type/classreading/CachingMetadataReaderFactory.java index 6a1d73aa4f..9c50de92d1 100644 --- a/spring-core/src/main/java/org/springframework/core/type/classreading/CachingMetadataReaderFactory.java +++ b/spring-core/src/main/java/org/springframework/core/type/classreading/CachingMetadataReaderFactory.java @@ -149,6 +149,10 @@ public class CachingMetadataReaderFactory extends SimpleMetadataReaderFactory { this.metadataReaderCache.clear(); } } + else if (this.metadataReaderCache != null) { + // Shared resource cache -> reset to local cache. + setCacheLimit(DEFAULT_CACHE_LIMIT); + } } @@ -159,6 +163,7 @@ public class CachingMetadataReaderFactory extends SimpleMetadataReaderFactory { public LocalResourceCache(int cacheLimit) { super(cacheLimit, 0.75f, true); + this.cacheLimit = cacheLimit; } public void setCacheLimit(int cacheLimit) {