Skip to content

[버그] redis conifg의 의도하지 않은 jackson 전역설정 수정#82

Merged
jam9582 merged 3 commits intodevelopfrom
hotfix/#81-redisConfig-global-error
Aug 7, 2025
Merged

[버그] redis conifg의 의도하지 않은 jackson 전역설정 수정#82
jam9582 merged 3 commits intodevelopfrom
hotfix/#81-redisConfig-global-error

Conversation

@jam9582
Copy link
Contributor

@jam9582 jam9582 commented Aug 7, 2025

🚀 What’s this PR about?

  • redis conifg의 의도하지 않은 jackson 전역설정 수정
  • studyroom 도메인에서 제가 redis config 파일을 건들기 전으로 커밋 불러와서 돌려놨습니다.

Summary by CodeRabbit

  • 신규 기능

    • Redis 연동을 위한 새로운 설정이 추가되어, 다양한 객체 타입과 캐싱 만료 시간(30분) 지원이 개선되었습니다.
  • 문서

    • Redis 설정 관련 주석이 최신 구성에 맞게 업데이트되었습니다.

@jam9582 jam9582 self-assigned this Aug 7, 2025
Copilot AI review requested due to automatic review settings August 7, 2025 01:52
@jam9582 jam9582 added the 버그 버그를 해결합니다. label Aug 7, 2025
@coderabbitai
Copy link

coderabbitai bot commented Aug 7, 2025

Note

Other AI code review bot(s) detected

CodeRabbit 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.

Walkthrough

Redis 설정 관련 코드가 리팩토링되었습니다. 기존 RedisConfig의 ObjectMapper 설정 및 직렬화 방식이 변경되었고, 별도의 임시 Redis 설정 클래스가 추가되어 다양한 RedisTemplate과 CacheManager Bean이 정의되었습니다. 각 Bean은 직렬화 및 TTL 등 세부 설정이 달라졌습니다.

Changes

Cohort / File(s) Change Summary
RedisConfig 리팩토링
src/main/java/org/example/hugmeexp/global/common/config/RedisConfig.java
CacheManager Bean에서 JavaTimeModule 등록 및 WRITE_DATES_AS_TIMESTAMPS 비활성화 제거, key 직렬화 규칙 단순화, 주석 수정
임시 Redis 설정 추가
temp_redis_config.java
RedisTemplate 및 CacheManager Bean을 정의하는 새로운 Redis 설정 클래스 추가, 다양한 직렬화 및 TTL 설정 적용

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: 데이터 저장/조회 (설정된 직렬화 방식 적용)
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related issues

Poem

🐰
Redis 설정 새로 짜니
직렬화 방식도 달라졌지
키와 값, 시간도 맞춰
캐시도 템플릿도 새로워
토끼는 오늘도 깡총깡총,
코드 속에서 춤을 춰!

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch hotfix/#81-redisConfig-global-error

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@jam9582 jam9582 linked an issue Aug 7, 2025 that may be closed by this pull request
1 task
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@github-actions
Copy link

github-actions bot commented Aug 7, 2025

Unit Test Results

359 tests   332 ✔️  13s ⏱️
  48 suites    27 💤
  48 files        0

Results for commit a068348.

♻️ This comment has been updated with latest results.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 60a965e and 653d5f3.

📒 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());

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (1)
src/main/java/org/example/hugmeexp/global/common/config/RedisConfig.java (1)

71-85: 메서드명 중복 및 일관성 문제

  1. 컴파일 오류: 동일한 메서드명 customStringRedisTemplate이 44번 줄과 76번 줄에 중복 정의되어 있습니다.
  2. 연결 팩토리 불일치: 다른 템플릿들은 redisConnectionFactory()를 사용하는데 이 메서드만 파라미터로 받습니다.
  3. 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

📥 Commits

Reviewing files that changed from the base of the PR and between 653d5f3 and 6acc324.

📒 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.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6acc324 and a068348.

📒 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 목적에 부합합니다.

@jam9582 jam9582 merged commit 518eefe into develop Aug 7, 2025
3 checks passed
@jam9582 jam9582 deleted the hotfix/#81-redisConfig-global-error branch August 7, 2025 02:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

버그 버그를 해결합니다.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[버그] redis config 전역 설정 에러

3 participants

Comments