[버그] redis conifg의 의도하지 않은 jackson 전역설정 수정#82
Conversation
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. WalkthroughRedis 설정 관련 코드가 리팩토링되었습니다. 기존 RedisConfig의 ObjectMapper 설정 및 직렬화 방식이 변경되었고, 별도의 임시 Redis 설정 클래스가 추가되어 다양한 RedisTemplate과 CacheManager Bean이 정의되었습니다. 각 Bean은 직렬화 및 TTL 등 세부 설정이 달라졌습니다. Changes
Sequence Diagram(s)sequenceDiagram
participant Application
participant RedisConfig
participant Redis
Application->>RedisConfig: Bean 요청 (RedisTemplate, CacheManager)
RedisConfig->>Redis: RedisConnectionFactory로 연결
RedisConfig-->>Application: RedisTemplate, CacheManager 반환 (설정된 직렬화/TTL 포함)
Application->>Redis: 데이터 저장/조회 (설정된 직렬화 방식 적용)
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related issues
Poem
Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. ✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Pull Request Overview
This PR addresses an unintended Jackson global configuration issue in Redis configuration by creating a dedicated JacksonConfig and refactoring RedisConfig to use dependency injection for ObjectMapper management.
Key changes:
- Created a centralized JacksonConfig with global ObjectMapper bean
- Refactored RedisConfig to inject ObjectMapper instead of creating new instances
- Added domain-specific Redis templates for different use cases
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/main/java/org/example/hugmeexp/global/common/config/RedisConfig.java | Refactored to use injected ObjectMapper and added multiple specialized Redis templates for different domains |
| src/main/java/org/example/hugmeexp/global/common/config/JacksonConfig.java | New configuration class providing centralized ObjectMapper bean with global settings |
src/main/java/org/example/hugmeexp/global/common/config/RedisConfig.java
Outdated
Show resolved
Hide resolved
src/main/java/org/example/hugmeexp/global/common/config/RedisConfig.java
Show resolved
Hide resolved
src/main/java/org/example/hugmeexp/global/common/config/RedisConfig.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (2)
src/main/java/org/example/hugmeexp/global/common/config/JacksonConfig.java(1 hunks)src/main/java/org/example/hugmeexp/global/common/config/RedisConfig.java(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
src/main/java/org/example/hugmeexp/global/common/config/JacksonConfig.java (1)
src/main/java/org/example/hugmeexp/global/common/config/RedisConfig.java (1)
Configuration(20-110)
src/main/java/org/example/hugmeexp/global/common/config/RedisConfig.java (1)
src/main/java/org/example/hugmeexp/global/common/config/JacksonConfig.java (1)
Configuration(10-21)
🔇 Additional comments (3)
src/main/java/org/example/hugmeexp/global/common/config/JacksonConfig.java (1)
10-21: 전역 Jackson 설정 분리가 적절합니다!Redis 설정에서 Jackson 설정을 분리하여 전역 ObjectMapper를 제공하는 것은 좋은 접근입니다. 이렇게 하면 애플리케이션 전체에서 일관된 JSON 직렬화/역직렬화 동작을 보장할 수 있습니다.
src/main/java/org/example/hugmeexp/global/common/config/RedisConfig.java (2)
23-27: ObjectMapper 의존성 주입이 적절합니다!생성자 주입을 통해 전역 ObjectMapper를 받아오는 방식이 좋습니다. 이로써 Redis 설정이 더 이상 Jackson의 전역 설정을 직접 수정하지 않게 되었습니다.
99-109: ConnectionFactory 사용 방식 일관성 확인 필요다른 RedisTemplate들은
redisConnectionFactory()메서드를 사용하는 반면, 이 메서드는 파라미터로RedisConnectionFactory를 받아 사용합니다. 의도적인 설계인지 확인이 필요합니다.만약 동일한 연결 팩토리를 사용하려면:
- public RedisTemplate<String, String> customStringRedisTemplate(RedisConnectionFactory connectionFactory) { + public RedisTemplate<String, String> customStringRedisTemplate() { RedisTemplate<String, String> template = new RedisTemplate<>(); - template.setConnectionFactory(connectionFactory); + template.setConnectionFactory(redisConnectionFactory());
src/main/java/org/example/hugmeexp/global/common/config/RedisConfig.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (1)
src/main/java/org/example/hugmeexp/global/common/config/RedisConfig.java (1)
71-85: 메서드명 중복 및 일관성 문제
- 컴파일 오류: 동일한 메서드명
customStringRedisTemplate이 44번 줄과 76번 줄에 중복 정의되어 있습니다.- 연결 팩토리 불일치: 다른 템플릿들은
redisConnectionFactory()를 사용하는데 이 메서드만 파라미터로 받습니다.- afterPropertiesSet() 불일치: 이 템플릿만
afterPropertiesSet()을 호출합니다.메서드명을 변경하고 일관된 패턴을 사용하세요:
- @Bean("customStringRedisTemplate") - public RedisTemplate<String, String> customStringRedisTemplate(RedisConnectionFactory connectionFactory) { + @Bean("jwtRedisTemplate") + public RedisTemplate<String, String> jwtRedisTemplate() { RedisTemplate<String, String> template = new RedisTemplate<>(); - template.setConnectionFactory(connectionFactory); + template.setConnectionFactory(redisConnectionFactory()); template.setKeySerializer(new StringRedisSerializer()); template.setValueSerializer(new StringRedisSerializer()); template.setHashKeySerializer(new StringRedisSerializer()); template.setHashValueSerializer(new StringRedisSerializer()); - template.afterPropertiesSet(); return template; }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (1)
src/main/java/org/example/hugmeexp/global/common/config/RedisConfig.java(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/main/java/org/example/hugmeexp/global/common/config/RedisConfig.java (1)
src/main/java/org/example/hugmeexp/global/common/config/JacksonConfig.java (1)
Configuration(10-21)
🔇 Additional comments (2)
src/main/java/org/example/hugmeexp/global/common/config/RedisConfig.java (2)
23-27: ObjectMapper 주입 방식 개선 👍Redis 설정에서 ObjectMapper를 직접 생성하지 않고 주입받도록 변경한 것은 좋은 개선입니다. 이로써 Jackson 전역 설정에 영향을 주지 않게 되었습니다.
44-44: customStringRedisTemplate 오버로딩으로 컴파일 오류가 없습니다RedisConfig.java에 선언된 두 메서드는 시그니처가 달라 정상적인 오버로딩이며, 컴파일 오류가 발생하지 않습니다.
- 44행:
public RedisTemplate<String, String> customStringRedisTemplate()- 76행:
public RedisTemplate<String, String> customStringRedisTemplate(RedisConnectionFactory connectionFactory)기존 리뷰 코멘트는 오버로딩 특성을 반영하지 않은 잘못된 지적이므로 무시해 주세요.
Likely an incorrect or invalid review comment.
src/main/java/org/example/hugmeexp/global/common/config/RedisConfig.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (2)
src/main/java/org/example/hugmeexp/global/common/config/RedisConfig.java(1 hunks)temp_redis_config.java(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: build
🔇 Additional comments (1)
src/main/java/org/example/hugmeexp/global/common/config/RedisConfig.java (1)
63-69: 전역 Jackson 설정 수정이 적절하게 적용되었습니다.CacheManager의 ObjectMapper에서 JavaTimeModule 등록과 WRITE_DATES_AS_TIMESTAMPS 비활성화를 제거하여 의도하지 않은 전역 Jackson 설정 문제를 해결했습니다. 제네릭 컬렉션 타입 처리에 집중하는 현재 구성이 PR 목적에 부합합니다.
🚀 What’s this PR about?
Summary by CodeRabbit
신규 기능
문서