AnnotationUtils.clearCache() includes all annotation caches
Closes gh-31170
This commit is contained in:
parent
268043e9c9
commit
78fce80c43
|
@ -1081,6 +1081,9 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader
|
||||||
// Let subclasses do some final clean-up if they wish...
|
// Let subclasses do some final clean-up if they wish...
|
||||||
onClose();
|
onClose();
|
||||||
|
|
||||||
|
// Reset common introspection caches to avoid class reference leaks.
|
||||||
|
resetCommonCaches();
|
||||||
|
|
||||||
// Reset local application listeners to pre-refresh state.
|
// Reset local application listeners to pre-refresh state.
|
||||||
if (this.earlyApplicationListeners != null) {
|
if (this.earlyApplicationListeners != null) {
|
||||||
this.applicationListeners.clear();
|
this.applicationListeners.clear();
|
||||||
|
|
|
@ -1326,6 +1326,9 @@ public abstract class AnnotationUtils {
|
||||||
public static void clearCache() {
|
public static void clearCache() {
|
||||||
AnnotationTypeMappings.clearCache();
|
AnnotationTypeMappings.clearCache();
|
||||||
AnnotationsScanner.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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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]);
|
static final AttributeMethods NONE = new AttributeMethods(null, new Method[0]);
|
||||||
|
|
||||||
|
static final Map<Class<? extends Annotation>, AttributeMethods> cache = new ConcurrentReferenceHashMap<>();
|
||||||
private static final Map<Class<? extends Annotation>, AttributeMethods> cache =
|
|
||||||
new ConcurrentReferenceHashMap<>();
|
|
||||||
|
|
||||||
private static final Comparator<Method> methodComparator = (m1, m2) -> {
|
private static final Comparator<Method> methodComparator = (m1, m2) -> {
|
||||||
if (m1 != null && m2 != null) {
|
if (m1 != null && m2 != null) {
|
||||||
|
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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 = "jakarta.annotation.Priority";
|
private static final String JAVAX_PRIORITY_ANNOTATION = "jakarta.annotation.Priority";
|
||||||
|
|
||||||
/** Cache for @Order value (or NOT_ANNOTATED marker) per Class. */
|
/** 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 {
|
public abstract class RepeatableContainers {
|
||||||
|
|
||||||
|
static final Map<Class<? extends Annotation>, Object> cache = new ConcurrentReferenceHashMap<>();
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private final RepeatableContainers parent;
|
private final RepeatableContainers parent;
|
||||||
|
|
||||||
|
@ -141,8 +143,6 @@ public abstract class RepeatableContainers {
|
||||||
*/
|
*/
|
||||||
private static class StandardRepeatableContainers extends 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 final Object NONE = new Object();
|
||||||
|
|
||||||
private static final StandardRepeatableContainers INSTANCE = new StandardRepeatableContainers();
|
private static final StandardRepeatableContainers INSTANCE = new StandardRepeatableContainers();
|
||||||
|
|
Loading…
Reference in New Issue