11package com .axon .core_service .config ;
22
3- import com .fasterxml .jackson .annotation .JsonTypeInfo ;
43import com .fasterxml .jackson .databind .ObjectMapper ;
5- import com .fasterxml .jackson .databind .jsontype .impl .LaissezFaireSubTypeValidator ;
64import com .fasterxml .jackson .datatype .jsr310 .JavaTimeModule ;
75import java .time .Duration ;
86import org .springframework .cache .annotation .EnableCaching ;
@@ -25,22 +23,18 @@ public class CacheConfig {
2523
2624 /**
2725 * Configure ObjectMapper for Redis JSON serialization.
28- * Enables polymorphic type handling and Java 8 time support .
26+ * Only registers JavaTimeModule - GenericJackson2JsonRedisSerializer handles type info .
2927 */
3028 private ObjectMapper cacheObjectMapper () {
3129 ObjectMapper mapper = new ObjectMapper ();
3230
3331 // Register Java 8 date/time module for LocalDateTime serialization
3432 mapper .registerModule (new JavaTimeModule ());
3533
36- // Enable polymorphic type handling with WRAPPER_ARRAY format
37- // This wraps type information in an array: ["com.example.Type", {...}]
38- // More compatible with collections and complex types
39- mapper .activateDefaultTyping (
40- LaissezFaireSubTypeValidator .instance ,
41- ObjectMapper .DefaultTyping .NON_FINAL ,
42- JsonTypeInfo .As .WRAPPER_ARRAY // Changed from PROPERTY to WRAPPER_ARRAY
43- );
34+ // NOTE: Do NOT use activateDefaultTyping() here!
35+ // GenericJackson2JsonRedisSerializer already handles polymorphic types
36+ // using its own @class property mechanism. Adding activateDefaultTyping
37+ // causes double type wrapping and deserialization errors.
4438
4539 return mapper ;
4640 }
0 commit comments