Skip to content

Commit 22bd8bd

Browse files
committed
Skip serialization of potentially non-serializable cached state
Closes gh-36346
1 parent 9b10bb5 commit 22bd8bd

2 files changed

Lines changed: 20 additions & 4 deletions

File tree

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,13 +123,13 @@ public class ResolvableType implements Serializable {
123123

124124
private @Nullable Class<?> resolved;
125125

126-
private volatile @Nullable ResolvableType superType;
126+
private transient volatile @Nullable ResolvableType superType;
127127

128-
private volatile ResolvableType @Nullable [] interfaces;
128+
private transient volatile ResolvableType @Nullable [] interfaces;
129129

130-
private volatile ResolvableType @Nullable [] generics;
130+
private transient volatile ResolvableType @Nullable [] generics;
131131

132-
private volatile @Nullable Boolean unresolvableGenerics;
132+
private transient volatile @Nullable Boolean unresolvableGenerics;
133133

134134

135135
/**

spring-core/src/test/java/org/springframework/core/ResolvableTypeTests.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1335,6 +1335,22 @@ void serialize() throws Exception {
13351335
assertThat(deserializedNone).isSameAs(ResolvableType.NONE);
13361336
}
13371337

1338+
@Test
1339+
void serializeWithCachedState() throws Exception {
1340+
ResolvableType type = ResolvableType.forClass(List.class);
1341+
testSerialization(type);
1342+
type.getSuperType();
1343+
type.getInterfaces();
1344+
type.getGenerics();
1345+
type.hasUnresolvableGenerics();
1346+
testSerialization(type);
1347+
type.getSuperType();
1348+
type.getInterfaces();
1349+
type.getGenerics();
1350+
type.hasUnresolvableGenerics();
1351+
testSerialization(type);
1352+
}
1353+
13381354
@Test
13391355
void canResolveVoid() {
13401356
ResolvableType type = ResolvableType.forClass(void.class);

0 commit comments

Comments
 (0)