diff --git a/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/common/aop/event/EventPublisherAspect.kt b/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/common/aop/event/EventPublisherAspect.kt index 385cba8a..226afdf3 100644 --- a/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/common/aop/event/EventPublisherAspect.kt +++ b/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/common/aop/event/EventPublisherAspect.kt @@ -17,7 +17,7 @@ class EventPublisherAspect : ApplicationEventPublisherAware { private val appliedLocal: ThreadLocal = ThreadLocal.withInitial { false } @Around("@annotation(org.springframework.transaction.annotation.Transactional)") - fun handleEvent(joinPoint: ProceedingJoinPoint): Any { + fun handleEvent(joinPoint: ProceedingJoinPoint): Any? { val appliedValue = appliedLocal.get() // nested를 쓰는이유 // 트랜잭션 안에 트랜잭션이 또있는 경우대비 diff --git a/Whatnow-Infrastructure/src/main/kotlin/com/depromeet/whatnow/config/redis/RedisCacheConfig.kt b/Whatnow-Infrastructure/src/main/kotlin/com/depromeet/whatnow/config/redis/RedisCacheConfig.kt index cd64db46..6b0268dd 100644 --- a/Whatnow-Infrastructure/src/main/kotlin/com/depromeet/whatnow/config/redis/RedisCacheConfig.kt +++ b/Whatnow-Infrastructure/src/main/kotlin/com/depromeet/whatnow/config/redis/RedisCacheConfig.kt @@ -1,5 +1,8 @@ package com.depromeet.whatnow.config.redis +import com.fasterxml.jackson.databind.ObjectMapper +import com.fasterxml.jackson.databind.jsontype.BasicPolymorphicTypeValidator +import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper import org.springframework.cache.CacheManager import org.springframework.cache.annotation.EnableCaching import org.springframework.context.annotation.Bean @@ -16,6 +19,14 @@ import java.time.Duration @Configuration class RedisCacheConfig { + val objectMapper: ObjectMapper = jacksonObjectMapper() + .activateDefaultTyping( + BasicPolymorphicTypeValidator.builder() + .allowIfBaseType(Any::class.java) + .build(), + ObjectMapper.DefaultTyping.EVERYTHING, + ) + @Bean fun oidcCacheManager(cf: RedisConnectionFactory): CacheManager { val redisCacheConfiguration = RedisCacheConfiguration.defaultCacheConfig() @@ -25,9 +36,10 @@ class RedisCacheConfig { ), ) .serializeValuesWith( - RedisSerializationContext.SerializationPair.fromSerializer( - GenericJackson2JsonRedisSerializer(), - ), + RedisSerializationContext.SerializationPair + .fromSerializer( + GenericJackson2JsonRedisSerializer(objectMapper), + ), ) .entryTtl(Duration.ofDays(7L)) return RedisCacheManager.RedisCacheManagerBuilder.fromConnectionFactory(cf)