Skip to content

Commit aa663e6

Browse files
authored
add JsoniterSpi.clearCaches
since the cache may contain entries referring to classes whose classloader is disposed, there must be a way to get rid of them
1 parent e48a7a1 commit aa663e6

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/main/java/com/jsoniter/spi/JsoniterSpi.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,15 @@ private synchronized static void addObjectFactory(Class clazz, Extension extensi
291291
objectFactories = copy;
292292
}
293293

294+
public static synchronized void clearCaches() {
295+
mapKeyEncoders = new HashMap<>();
296+
mapKeyDecoders = new HashMap<>();
297+
encoders = new HashMap<>();
298+
decoders = new HashMap<>();
299+
objectFactories = new HashMap<>();
300+
}
301+
302+
294303
private static class TypeProperty {
295304

296305
public final Type type;

0 commit comments

Comments
 (0)