Skip to content

[Fix/fix-common-responses] - Jackson Binding을 위한 기본생성자#70

Merged
jeeheaG merged 1 commit intomainfrom
fix/jackson-field-mapping
Apr 30, 2025
Merged

[Fix/fix-common-responses] - Jackson Binding을 위한 기본생성자#70
jeeheaG merged 1 commit intomainfrom
fix/jackson-field-mapping

Conversation

@ekgns33
Copy link
Copy Markdown
Contributor

@ekgns33 ekgns33 commented Apr 30, 2025

작업내역

  • Jackson은 기본생성자 + getter, setter조합을 사용하여 매핑과 직렬화를합니다.
    • 기존 코드에서 final을 사용하여 기본생성자 없이사용했는데, 이 경우에는 생성자를 통해 바인딩을 하게됩니다. 따라서 의도치 않은 객체가 응답에 추가되는 오류가 발생했습니다.
{
  "errorCode": {
    "client_message": "string",
    "http_status_code": "CONTINUE",
    "log_message": "string",
    "code": "string"
  },
  "temporal_register_token": "string",
  "success": true,
  "message": "string",
  "code": "string"
}
  • final을 지우고 기본생성자를 추가하여 Getter을 통한 매핑이 가능하도록 변경했습니다.

Summary by CodeRabbit

  • Refactor

    • Improved flexibility of error and response handling, allowing for easier extension and integration with frameworks.
    • Adjusted internal structures to support mutable fields and enhanced subclassing capabilities for error responses.
  • Chores

    • Updated constructors and inheritance for consistency across response-related classes.

@ekgns33 ekgns33 requested a review from jeeheaG April 30, 2025 02:09
@ekgns33 ekgns33 self-assigned this Apr 30, 2025
@ekgns33 ekgns33 added the bug Something isn't working label Apr 30, 2025
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 30, 2025

Walkthrough

The changes introduce adjustments to the error response hierarchy and mutability of response classes. The ErrorResponse class now has a protected no-argument constructor, and its constructors' visibility and logic have been updated. The Response class fields are no longer final and now have a protected no-argument constructor. The RegisterErrorResponse class now extends ErrorResponse instead of Response, its field mutability has changed, and it also gains a protected no-argument constructor. These modifications collectively enhance flexibility for subclassing and framework integration.

Changes

File(s) Change Summary
src/main/java/org/runimo/runimo/common/response/ErrorResponse.java Added a protected no-argument constructor via Lombok. Changed the visibility of the (String, String) constructor from private to protected. Removed the private constructor accepting a CustomResponseCode. Updated the static factory method to construct instances using the new constructor.
src/main/java/org/runimo/runimo/common/response/Response.java Made success, message, and code fields mutable (removed final). Added a protected no-argument constructor via Lombok for subclassing and framework compatibility.
src/main/java/org/runimo/runimo/exceptions/RegisterErrorResponse.java Changed superclass from Response to ErrorResponse. Added a protected no-argument constructor via Lombok. Made temporalRegisterToken field mutable (removed final). Updated constructor to call new superclass constructor signature.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant RegisterErrorResponse
    participant ErrorResponse
    participant CustomResponseCode

    Client->>RegisterErrorResponse: create(errorCode, temporalRegisterToken)
    RegisterErrorResponse->>ErrorResponse: super(errorCode.getClientMessage(), errorCode.getCode())
    RegisterErrorResponse->>RegisterErrorResponse: setTemporalRegisterToken(temporalRegisterToken)
Loading

Poem

In the warren of code, constructors now hide,
Protected and mutable, fields open wide.
Errors and responses, with hierarchy anew,
Tokens can change, as rabbits hop through.
With every refactor, our classes align—
A hop, a skip, and all works fine!
🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Free

📥 Commits

Reviewing files that changed from the base of the PR and between 7f8f83a and 6bbddeb.

📒 Files selected for processing (3)
  • src/main/java/org/runimo/runimo/common/response/ErrorResponse.java (1 hunks)
  • src/main/java/org/runimo/runimo/common/response/Response.java (1 hunks)
  • src/main/java/org/runimo/runimo/exceptions/RegisterErrorResponse.java (1 hunks)

Note

🎁 Summarized by CodeRabbit Free

Your organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login.

🪧 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • 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 generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

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 sequence diagram to generate a sequence diagram of the changes in 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.

Copy link
Copy Markdown
Contributor

@jeeheaG jeeheaG left a comment

Choose a reason for hiding this comment

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

고생하셨습니다~

수정을 요하는 건 아니고 그냥 궁금한 게 있는데
의도치 않은 객체가 null 상태로 추가되는 거면 JsonInclude.Include.NON_NULL 로는 해결이 안되었나요?

@ekgns33
Copy link
Copy Markdown
Contributor Author

ekgns33 commented Apr 30, 2025

@jeeheaG

수정을 요하는 건 아니고 그냥 궁금한 게 있는데 의도치 않은 객체가 null 상태로 추가되는 거면 JsonInclude.Include.NON_NULL 로는 해결이 안되었나요?

음.. 필드값이 아니라 파라매터값인데 응답에 포함되는경우라 어노테이션을 찾아보진 않았던것같아요.

@jeeheaG
Copy link
Copy Markdown
Contributor

jeeheaG commented Apr 30, 2025

넵 머지시킬게여~~

@jeeheaG jeeheaG merged commit aed4d24 into main Apr 30, 2025
3 checks passed
@jeeheaG jeeheaG deleted the fix/jackson-field-mapping branch April 30, 2025 07:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants