fix: ReviewDetailV1 NPE 위험 수정#402
Conversation
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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은 V2 리뷰 데이터 구조와 호환되는 리뷰 조회 시 발생하는 NPE 문제를 해결합니다. Ratings 객체가 없는 경우에도 V1 응답 모델이 정상적으로 데이터를 처리할 수 있도록 null 체크 로직을 추가하여 시스템 안정성을 높였습니다. Highlights
New Features🧠 You can now enable Memory (public preview) 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. 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 the 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 counterproductive. 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. 리뷰의 별점 확인하려다, 널(null)을 만나 멈춰버린 코드. 안전하게 확인하고, 다시 흐르는 서비스의 길. Footnotes
|
There was a problem hiding this comment.
Code Review
이번 풀 리퀘스트는 ReviewDetailV1 DTO에서 ratings 객체가 null일 때 발생할 수 있는 NullPointerException을 방지하기 위해 null 검사를 추가하고, 기본값으로 review.getRating()을 사용하도록 수정하였습니다. 이에 대해 ratings와 review.getRating()이 모두 null인 경우 mainRating이 null이 될 수 있으므로 Objects.requireNonNull 등을 사용해 null 검증을 하거나 기본값을 제공하라는 피드백이 있었습니다.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| Ratings ratings = review.getRatings(); | ||
| Integer mainRating = (ratings != null) ? ratings.getMainRating() : review.getRating(); | ||
| Integer amountRating = (ratings != null) ? ratings.getAmountRating() : null; | ||
| Integer tasteRating = (ratings != null) ? ratings.getTasteRating() : null; |
There was a problem hiding this comment.
[pooreumjung, 2026-07-09] ratings와 review.getRating()이 모두 null인 경우 mainRating이 null이 될 수 있으므로, Objects.requireNonNull 등을 사용하여 null 검증을 하거나 기본값을 제공하는 것이 안전합니다.
| Ratings ratings = review.getRatings(); | |
| Integer mainRating = (ratings != null) ? ratings.getMainRating() : review.getRating(); | |
| Integer amountRating = (ratings != null) ? ratings.getAmountRating() : null; | |
| Integer tasteRating = (ratings != null) ? ratings.getTasteRating() : null; | |
| Ratings ratings = review.getRatings(); | |
| Integer mainRating = (ratings != null) ? ratings.getMainRating() : java.util.Objects.requireNonNull(review.getRating(), "Rating must not be null"); | |
| Integer amountRating = (ratings != null) ? ratings.getAmountRating() : null; | |
| Integer tasteRating = (ratings != null) ? ratings.getTasteRating() : null; |
#️⃣ Issue Number
📝 요약(Summary)
ReviewDetailV1.from()이review.getRatings()가 null일 때(V2 경로로 생성되어rating필드만 채워진 리뷰)getMainRating()호출에서 NPE가 발생하던 문제를 수정했습니다.ReviewDetail.from()에 이미 있던rating != null ? rating : ratings.getMainRating()null-safe 패턴을 V1에도 동일하게 적용했습니다.ratings가 null인 경우amountRating/tasteRating은 V2 리뷰에 애초에 값이 없으므로 그대로 null을 반환합니다.💬 공유사항 to 리뷰어
Review.ratings/Review.rating이 서로 배타적으로 채워지는 케이스에 대한 테스트가 없다면 이번 기회에 추가하는 것도 고려해볼 만합니다.✅ PR Checklist
PR이 다음 요구 사항을 충족하는지 확인하세요.