Skip to content

FEATURE: Add ForceSerializeForCollection to GenericJsonSerializingTranscoder#1046

Open
oliviarla wants to merge 1 commit intonaver:developfrom
oliviarla:tc2
Open

FEATURE: Add ForceSerializeForCollection to GenericJsonSerializingTranscoder#1046
oliviarla wants to merge 1 commit intonaver:developfrom
oliviarla:tc2

Conversation

@oliviarla
Copy link
Collaborator

@oliviarla oliviarla commented Feb 20, 2026

🔗 Related Issue

⌨️ What I did

  • GenericJsonSerializingTranscoder 수정 사항
    • forceJDKSerializeForCollection 옵션이 현재 SerializingTranscoder에서만 제공되고 있습니다.
    • GenericJsonSerializingTranscoder에서도 해당 기능을 제공하여 다양한 객체 타입을 collection에 저장할 수 있도록 합니다.
    • SerializingTranscoder와 유사하게 구조를 변경하였습니다.
      • isCollection, forceJsonSerializeForCollection 변수를 추가하였으며 이로 인해 설정 요소들이 많아져 빌더 패턴으로 생성하도록 수정하였습니다.
  • 테스트 코드 수정 사항
    • 기존 CollectionTranscoderTest는 사실상 SerializingTranscoderforceSerializeForCollection 동작을 확인하는 클래스였습니다.
    • 따라서 SerializingTranscoder, GenericJsonSerializingTranscoder 모두 확인하는 ForceSerializeTranscoderTest 클래스를 사용하도록 수정하였습니다.

@oliviarla oliviarla requested a review from uhm0311 February 20, 2026 01:37
@oliviarla oliviarla requested a review from jhpark816 February 20, 2026 02:04
Copy link
Collaborator

@jhpark816 jhpark816 left a comment

Choose a reason for hiding this comment

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

리뷰 완료

}

if ((d.getFlags() & COMPRESSED) != 0) {
if (!isCollection && (d.getFlags() & COMPRESSED) != 0) {
Copy link
Collaborator

@jhpark816 jhpark816 Feb 20, 2026

Choose a reason for hiding this comment

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

!isCollection 조건은 없어야 할 것 같습니다.
이미 COMPRESSED 상태이면, decompress 해야 하기 때문입니다.

byte[] b;
int flags = 0;

if (isCollection && forceJsonSerializeForCollection) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

isCollection == false이면
forceJsonSerializeForCollection == true이더라도 serialize() 하지 않는군요.

forceJsonSerializeForCollection 조건에 의해 serialize() 여부가 결정되는 것이
나을 것 같습니다.

}
assert b != null;
if (cu.isCompressionCandidate(b)) {
if (!isCollection && cu.isCompressionCandidate(b)) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

isCollection은 collection element를 encode한다는 의미인가요?
collection 여부 보다는 compress 자체 기준에 따르는 것이 어떤가요?

@oliviarla
Copy link
Collaborator Author

@jhpark816
참고로 GenericJsonSerializingTranscoder의 encode/decode 로직은 SerializingTranscoder와 동일하도록 수정한 것입니다.
따라서 여기에서만 동작을 다르게 가져가면 이상할 것 같습니다.

코멘트에서 질문하신 점도 여기서 답변 드립니다.

  • SerializingTranscoder에서는 collection이 아닌 경우 압축을 고려하지 않음
  • SerializingTranscoder에서는 collection이 아닌 경우 forceJDKSerialize 옵션을 고려하지 않음 (애초에 collection에 서로 다른 타입을 넣기 위해 추가된 옵션이므로 key-value일 때 이 변수를 고려하는게 이상함)

@jhpark816
Copy link
Collaborator

!isCollection 조건은 없어야 할 것 같습니다.
이미 COMPRESSES 상태이면, decompress 해야 하기 때문입니다.

이 부분은 수정하는 것이 좋겠습니다.
SerializingTranscoder에서도 수정하고요.

private final CompressionUtils cu;
private final TranscoderUtils tu;
private final boolean isCollection;
private final boolean forceJsonSerializeForCollection;
Copy link
Collaborator

Choose a reason for hiding this comment

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

질문입니다.
forceJDKSerializeForCollection 용어를 사용해야 하지 않는 지?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ObectMapper 기반의 Json 변환을 하고 있으므로 JDKSerialize 방식을 사용하지 않습니다.
따라서 지금과 같이 변수명을 작성했습니다.

@oliviarla
Copy link
Collaborator Author

collection이면 compress되지 않기 때문에 decompress 고려할 필요가 없는데, 변경해야 하는 이유가 무엇인가요?

@jhpark816
Copy link
Collaborator

collection이면 compress되지 않기 때문에 decompress 고려할 필요가 없는데, 변경해야 하는 이유가 무엇인가요?

마찬가지 이유입니다.
collection이면 compress 되지 않기 때문에, (d.getFlags() & COMPRESSED) != 0 조건만 확인해도 충분합니다.
즉, !isCollection 조건을 확인하지 않아도 됩니다.

추가 이유는 코드 자체의 의미가 이상합니다.
COMPRESSED 데이터인데도 !isCollection이면 decompress 하지 않는다는 것입니다.
따라서, !isCollection 조건을 제거하는 것이 코드 자체의 의미적 표현에서도 나아 보입니다.

@jhpark816
Copy link
Collaborator

@oliviarla

isCollection && forceJsonSerializeForCollection

isCollection == false이면, forceJsonSerializeForCollection을 true로 설정할 수 없게 만들어 둔 상태입니다.
즉, forceJsonSerializeForCollection == true이면, isCollection == true 임이 보장됩니다.
따라서, forceJsonSerializeForCollection 조건만 확인하여도 충분하지만,
collection에 한하여 forceJsonSerializeForCollection 할 수 있음을 강조 표현한 코드로 이해하므로,
이 코드는 그대로 두는 것이 좋겠습니다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Comments