Memory leak with PathCache.cache growing due the map was not synchronized
closes #19096
This commit is contained in:
parent
827943571e
commit
1f5d3223ae
1 changed files with 3 additions and 2 deletions
|
@ -16,6 +16,7 @@
|
||||||
*/
|
*/
|
||||||
package org.keycloak.adapters.authorization;
|
package org.keycloak.adapters.authorization;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
@ -53,12 +54,12 @@ public class PathCache {
|
||||||
*/
|
*/
|
||||||
PathCache(final int maxEntries, long maxAge,
|
PathCache(final int maxEntries, long maxAge,
|
||||||
Map<String, PathConfig> paths) {
|
Map<String, PathConfig> paths) {
|
||||||
cache = new LinkedHashMap<String, CacheEntry>(16, DEFAULT_LOAD_FACTOR, true) {
|
cache = Collections.synchronizedMap(new LinkedHashMap<String, CacheEntry>(16, DEFAULT_LOAD_FACTOR, true) {
|
||||||
@Override
|
@Override
|
||||||
protected boolean removeEldestEntry(Map.Entry eldest) {
|
protected boolean removeEldestEntry(Map.Entry eldest) {
|
||||||
return cache.size() > maxEntries;
|
return cache.size() > maxEntries;
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
this.maxAge = maxAge;
|
this.maxAge = maxAge;
|
||||||
this.enabled = ! (maxAge < -1 || (maxAge > -1 && maxAge <= 0));
|
this.enabled = ! (maxAge < -1 || (maxAge > -1 && maxAge <= 0));
|
||||||
this.paths = paths;
|
this.paths = paths;
|
||||||
|
|
Loading…
Reference in a new issue