[Fix] xxxReviewListResponse의 non-null List 디코딩 문제를 해결합니다#485
[Fix] xxxReviewListResponse의 non-null List 디코딩 문제를 해결합니다#485
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! 이 PR은 백엔드 API 응답에서 리스트 내부에 Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
이 PR은 백엔드 API 응답에 포함된 null 값으로 인해 발생하는 kotlinx.serialization 디코딩 오류를 수정합니다. imageUrls와 menuList의 리스트 요소 타입을 nullable로 변경하고, toDomain() 함수에서 filterNotNull()을 사용하여 null 값을 안전하게 처리하도록 수정한 것은 올바른 접근입니다. 또한 ArrayList를 List로 변경하여 코드 품질을 개선한 점도 좋습니다.
전반적으로 변경 사항은 정확하지만, 몇 가지 성능 개선 기회를 발견했습니다. filterNotNull().map() 이나 filterNotNull().firstOrNull() 대신 더 효율적인 코틀린 컬렉션 함수를 사용하는 것을 제안합니다. 자세한 내용은 각 파일의 주석을 확인해주세요.
app/src/main/java/com/eatssu/android/data/remote/dto/response/MealReviewListResponse.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/com/eatssu/android/data/remote/dto/response/MenuReviewListResponse.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/com/eatssu/android/data/remote/dto/response/MyReviewListResponse.kt
Outdated
Show resolved
Hide resolved
filterNotNull().firstOrNull()은 리스트 전체를 순회하여 새로운 리스트를 만든 후 첫 번째 원소를 찾습니다. firstOrNull { it != null }을 사용하면 null이 아닌 첫 번째 원소를 찾는 즉시 순회를 멈추므로 더 효율적입니다.
PeraSite
left a comment
There was a problem hiding this comment.
확실히 직렬화나 백엔드 처리를 바꾸는건 무섭네요.. 👍
그래서 저나 유리님이 적극적으로 kotlinx.serialization 바꾸려고 안했던 거긴해여 허허 |
Summary
백엔드 API 응답에서 imageUrls나 menuList 배열 내부에 null 값이 포함되어 내려왔을 때,
kotlinx.serialization이 non-null 리스트(List)로 디코딩하려고 시도하면서 발생한 문제
Describe your changes
다음 파일들의 리스트 속성을 nullable(List<String?>, List<MenuList?>)로 변경하고, 이를 도메인 모델로 변환할 때(예: toDomain()) filterNotNull() 연산자를 추가하여 null 값을 안전하게 무시하도록 처리했습니다
Issue
To reviewers
잔존해있는 ArrayList를 List로 변경하고 디폴트 값도 lisfOf로 바꾸었습니다