Skip to content

Commit 262c702

Browse files
committed
CachingMetadataReaderFactory releases shared cache Map on clearCache()
LocalResourceCache properly initializes cacheLimit on construction. Issue: SPR-17527
1 parent 548126d commit 262c702

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

spring-core/src/main/java/org/springframework/core/type/classreading/CachingMetadataReaderFactory.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,10 @@ public void clearCache() {
149149
this.metadataReaderCache.clear();
150150
}
151151
}
152+
else if (this.metadataReaderCache != null) {
153+
// Shared resource cache -> reset to local cache.
154+
setCacheLimit(DEFAULT_CACHE_LIMIT);
155+
}
152156
}
153157

154158

@@ -159,6 +163,7 @@ private static class LocalResourceCache extends LinkedHashMap<Resource, Metadata
159163

160164
public LocalResourceCache(int cacheLimit) {
161165
super(cacheLimit, 0.75f, true);
166+
this.cacheLimit = cacheLimit;
162167
}
163168

164169
public void setCacheLimit(int cacheLimit) {

0 commit comments

Comments
 (0)