AnnotationUtils.clearCache() includes all annotation caches
Closes gh-31170
(cherry picked from commit 78fce80c43)
This commit is contained in:
@@ -1083,6 +1083,9 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader
|
||||
// Let subclasses do some final clean-up if they wish...
|
||||
onClose();
|
||||
|
||||
// Reset common introspection caches to avoid class reference leaks.
|
||||
resetCommonCaches();
|
||||
|
||||
// Reset local application listeners to pre-refresh state.
|
||||
if (this.earlyApplicationListeners != null) {
|
||||
this.applicationListeners.clear();
|
||||
|
||||
@@ -1321,6 +1321,9 @@ public abstract class AnnotationUtils {
|
||||
public static void clearCache() {
|
||||
AnnotationTypeMappings.clearCache();
|
||||
AnnotationsScanner.clearCache();
|
||||
AttributeMethods.cache.clear();
|
||||
RepeatableContainers.cache.clear();
|
||||
OrderUtils.orderCache.clear();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -39,9 +39,7 @@ final class AttributeMethods {
|
||||
|
||||
static final AttributeMethods NONE = new AttributeMethods(null, new Method[0]);
|
||||
|
||||
|
||||
private static final Map<Class<? extends Annotation>, AttributeMethods> cache =
|
||||
new ConcurrentReferenceHashMap<>();
|
||||
static final Map<Class<? extends Annotation>, AttributeMethods> cache = new ConcurrentReferenceHashMap<>();
|
||||
|
||||
private static final Comparator<Method> methodComparator = (m1, m2) -> {
|
||||
if (m1 != null && m2 != null) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -41,7 +41,7 @@ public abstract class OrderUtils {
|
||||
private static final String JAVAX_PRIORITY_ANNOTATION = "javax.annotation.Priority";
|
||||
|
||||
/** Cache for @Order value (or NOT_ANNOTATED marker) per Class. */
|
||||
private static final Map<AnnotatedElement, Object> orderCache = new ConcurrentReferenceHashMap<>(64);
|
||||
static final Map<AnnotatedElement, Object> orderCache = new ConcurrentReferenceHashMap<>(64);
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -43,6 +43,8 @@ import org.springframework.util.ObjectUtils;
|
||||
*/
|
||||
public abstract class RepeatableContainers {
|
||||
|
||||
static final Map<Class<? extends Annotation>, Object> cache = new ConcurrentReferenceHashMap<>();
|
||||
|
||||
@Nullable
|
||||
private final RepeatableContainers parent;
|
||||
|
||||
@@ -137,8 +139,6 @@ public abstract class RepeatableContainers {
|
||||
*/
|
||||
private static class StandardRepeatableContainers extends RepeatableContainers {
|
||||
|
||||
private static final Map<Class<? extends Annotation>, Object> cache = new ConcurrentReferenceHashMap<>();
|
||||
|
||||
private static final Object NONE = new Object();
|
||||
|
||||
private static StandardRepeatableContainers INSTANCE = new StandardRepeatableContainers();
|
||||
|
||||
Reference in New Issue
Block a user