Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 승인 과정에서 발생하는 npe 처리 #108

Merged
merged 8 commits into from
Feb 23, 2024

Conversation

Sangwook02
Copy link
Member

🌱 관련 이슈

📌 작업 내용 및 특이사항

  • querydsl의 transform에서는 해당하는 원소가 없으면 빈 리스트가 아니라 null을 반환하기 때문에 발생하는 NPE가 있음을 확인하고 수정했습니다.

📝 참고사항

📚 기타

@Sangwook02 Sangwook02 added 🐛 bug/error 버그 및 에러 픽스 ⚓ Domain: Admin 어드민 관련 작업 labels Feb 22, 2024
@Sangwook02 Sangwook02 self-assigned this Feb 22, 2024
@Sangwook02 Sangwook02 requested a review from a team as a code owner February 22, 2024 15:03
@@ -110,10 +112,15 @@ public Page<Member> findAllByPaymentStatus(RequirementStatus paymentStatus, Page

@Override
public Map<Boolean, List<Member>> groupByVerified(MemberGrantRequest request) {
Copy link
Member

Choose a reason for hiding this comment

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

파라미터 DTO로 안받도록 수정해주세요. 아까 체크 못했네요

Comment on lines 119 to 123

Map<Boolean, List<Member>> classifiedMember = new HashMap<>();
classifiedMember.put(true, groupByVerified.getOrDefault(true, new ArrayList<>()));
classifiedMember.put(false, groupByVerified.getOrDefault(false, new ArrayList<>()));
return classifiedMember;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Map<Boolean, List<Member>> classifiedMember = new HashMap<>();
classifiedMember.put(true, groupByVerified.getOrDefault(true, new ArrayList<>()));
classifiedMember.put(false, groupByVerified.getOrDefault(false, new ArrayList<>()));
return classifiedMember;
if (groupByVerified != null) {
return groupByVerified;
}
Map<Boolean, List<Member>> emptyMap = new HashMap<>();
emptyMap.put(true, new ArrayList<>());
emptyMap.put(false, new ArrayList<>());
return emptyMap;

Copy link
Member

@uwoobeat uwoobeat Feb 22, 2024

Choose a reason for hiding this comment

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

null 로직을 명확히 분리하면 좋을 것 같습니다 + early return

Copy link
Member Author

Choose a reason for hiding this comment

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

이게 true와 false 둘 중 하나만 null이 반환될 수 있어서 둘 다 if문으로 확인하느니 getOrDefault로 처리하는게 좋을 것 같습니다.
null 로직은 분리했습니다

Copy link
Member Author

Choose a reason for hiding this comment

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

if (groupByVerified.get(true) != null && groupByVerified.get(false) != null) {
    return groupByVerified;
}

return ensureNonNull(groupByVerified);

아니면 이렇게 되어야 할 것 같은데 뭔가 두번 확인하는 느낌이 나는 것 같지 않나요?

Copy link
Member

Choose a reason for hiding this comment

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

getOrDefault 좋습니다.

메서드 이름이 뭔가 검증하는 메서드 이름 같아서 딴걸로 한번 바꿔보시면 좋을 것 같아요
저도 마땅히 생각나는 건 없는데 한번 gpt한테 물어보고 정히 없으면 그냥 패스하는 걸로 하죠

일단 어푸드릴게요

Copy link
Member

@uwoobeat uwoobeat left a comment

Choose a reason for hiding this comment

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

어푸루푸

@Sangwook02 Sangwook02 merged commit eb523a7 into develop Feb 23, 2024
1 check passed
@Sangwook02 Sangwook02 deleted the fix/107-grant-npe branch February 23, 2024 03:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug/error 버그 및 에러 픽스 ⚓ Domain: Admin 어드민 관련 작업
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🐛 승인 과정에서 발생하는 NPE 제거
2 participants