Skip to content

Commit d643e57

Browse files
committed
ResolvableType.clearCache() clears SerializableTypeWrapper cache as well
Issue: SPR-15503 (cherry picked from commit 7ca0094)
1 parent 84d2e5a commit d643e57

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

spring-core/src/main/java/org/springframework/core/ResolvableType.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2017 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.
@@ -1356,11 +1356,12 @@ static ResolvableType forType(Type type, TypeProvider typeProvider, VariableReso
13561356
}
13571357

13581358
/**
1359-
* Clear the internal {@code ResolvableType} cache.
1359+
* Clear the internal {@code ResolvableType}/{@code SerializableTypeWrapper} cache.
13601360
* @since 4.2
13611361
*/
13621362
public static void clearCache() {
13631363
cache.clear();
1364+
SerializableTypeWrapper.cache.clear();
13641365
}
13651366

13661367

spring-core/src/main/java/org/springframework/core/SerializableTypeWrapper.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,7 @@ abstract class SerializableTypeWrapper {
5959
private static final Class<?>[] SUPPORTED_SERIALIZABLE_TYPES = {
6060
GenericArrayType.class, ParameterizedType.class, TypeVariable.class, WildcardType.class};
6161

62-
private static final ConcurrentReferenceHashMap<Type, Type> cache =
63-
new ConcurrentReferenceHashMap<Type, Type>(256);
62+
static final ConcurrentReferenceHashMap<Type, Type> cache = new ConcurrentReferenceHashMap<Type, Type>(256);
6463

6564

6665
/**
@@ -84,7 +83,7 @@ public static Type forMethodParameter(MethodParameter methodParameter) {
8483
*/
8584
@SuppressWarnings("serial")
8685
public static Type forGenericSuperclass(final Class<?> type) {
87-
return forTypeProvider(new DefaultTypeProvider() {
86+
return forTypeProvider(new SimpleTypeProvider() {
8887
@Override
8988
public Type getType() {
9089
return type.getGenericSuperclass();
@@ -100,7 +99,7 @@ public static Type[] forGenericInterfaces(final Class<?> type) {
10099
Type[] result = new Type[type.getGenericInterfaces().length];
101100
for (int i = 0; i < result.length; i++) {
102101
final int index = i;
103-
result[i] = forTypeProvider(new DefaultTypeProvider() {
102+
result[i] = forTypeProvider(new SimpleTypeProvider() {
104103
@Override
105104
public Type getType() {
106105
return type.getGenericInterfaces()[index];
@@ -118,7 +117,7 @@ public static Type[] forTypeParameters(final Class<?> type) {
118117
Type[] result = new Type[type.getTypeParameters().length];
119118
for (int i = 0; i < result.length; i++) {
120119
final int index = i;
121-
result[i] = forTypeProvider(new DefaultTypeProvider() {
120+
result[i] = forTypeProvider(new SimpleTypeProvider() {
122121
@Override
123122
public Type getType() {
124123
return type.getTypeParameters()[index];
@@ -198,10 +197,10 @@ interface TypeProvider extends Serializable {
198197

199198

200199
/**
201-
* Default implementation of {@link TypeProvider} with a {@code null} source.
200+
* Base implementation of {@link TypeProvider} with a {@code null} source.
202201
*/
203202
@SuppressWarnings("serial")
204-
private static abstract class DefaultTypeProvider implements TypeProvider {
203+
private static abstract class SimpleTypeProvider implements TypeProvider {
205204

206205
@Override
207206
public Object getSource() {

0 commit comments

Comments
 (0)