File tree Expand file tree Collapse file tree 5 files changed +12
-8
lines changed
spring-context/src/main/java/org/springframework/context/support
spring-core/src/main/java/org/springframework/core/annotation Expand file tree Collapse file tree 5 files changed +12
-8
lines changed Original file line number Diff line number Diff line change @@ -1081,6 +1081,9 @@ protected void doClose() {
1081
1081
// Let subclasses do some final clean-up if they wish...
1082
1082
onClose ();
1083
1083
1084
+ // Reset common introspection caches to avoid class reference leaks.
1085
+ resetCommonCaches ();
1086
+
1084
1087
// Reset local application listeners to pre-refresh state.
1085
1088
if (this .earlyApplicationListeners != null ) {
1086
1089
this .applicationListeners .clear ();
Original file line number Diff line number Diff line change @@ -1326,6 +1326,9 @@ public static boolean isSynthesizedAnnotation(@Nullable Annotation annotation) {
1326
1326
public static void clearCache () {
1327
1327
AnnotationTypeMappings .clearCache ();
1328
1328
AnnotationsScanner .clearCache ();
1329
+ AttributeMethods .cache .clear ();
1330
+ RepeatableContainers .cache .clear ();
1331
+ OrderUtils .orderCache .clear ();
1329
1332
}
1330
1333
1331
1334
Original file line number Diff line number Diff line change 1
1
/*
2
- * Copyright 2002-2022 the original author or authors.
2
+ * Copyright 2002-2023 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -39,9 +39,7 @@ final class AttributeMethods {
39
39
40
40
static final AttributeMethods NONE = new AttributeMethods (null , new Method [0 ]);
41
41
42
-
43
- private static final Map <Class <? extends Annotation >, AttributeMethods > cache =
44
- new ConcurrentReferenceHashMap <>();
42
+ static final Map <Class <? extends Annotation >, AttributeMethods > cache = new ConcurrentReferenceHashMap <>();
45
43
46
44
private static final Comparator <Method > methodComparator = (m1 , m2 ) -> {
47
45
if (m1 != null && m2 != null ) {
Original file line number Diff line number Diff line change 1
1
/*
2
- * Copyright 2002-2022 the original author or authors.
2
+ * Copyright 2002-2023 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -41,7 +41,7 @@ public abstract class OrderUtils {
41
41
private static final String JAVAX_PRIORITY_ANNOTATION = "jakarta.annotation.Priority" ;
42
42
43
43
/** Cache for @Order value (or NOT_ANNOTATED marker) per Class. */
44
- private static final Map <AnnotatedElement , Object > orderCache = new ConcurrentReferenceHashMap <>(64 );
44
+ static final Map <AnnotatedElement , Object > orderCache = new ConcurrentReferenceHashMap <>(64 );
45
45
46
46
47
47
/**
Original file line number Diff line number Diff line change 43
43
*/
44
44
public abstract class RepeatableContainers {
45
45
46
+ static final Map <Class <? extends Annotation >, Object > cache = new ConcurrentReferenceHashMap <>();
47
+
46
48
@ Nullable
47
49
private final RepeatableContainers parent ;
48
50
@@ -141,8 +143,6 @@ public static RepeatableContainers none() {
141
143
*/
142
144
private static class StandardRepeatableContainers extends RepeatableContainers {
143
145
144
- private static final Map <Class <? extends Annotation >, Object > cache = new ConcurrentReferenceHashMap <>();
145
-
146
146
private static final Object NONE = new Object ();
147
147
148
148
private static final StandardRepeatableContainers INSTANCE = new StandardRepeatableContainers ();
You can’t perform that action at this time.
0 commit comments