Skip to content

Commit 23d1049

Browse files
committed
CachingMetadataReaderFactory releases shared cache Map on clearCache()
LocalResourceCache properly initializes cacheLimit on construction. Issue: SPR-17527 (cherry picked from commit 262c702)
1 parent 37a50d7 commit 23d1049

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2017 the original author or authors.
2+
* Copyright 2002-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -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)