fix: 셔틀 잔여 시간 정렬 중 null 도착 시각 NPE 방지 - #2410
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe change removes premature shuttle arrival-time sorting and adds unit coverage for invalid times, duplicate departures, route variants, ordering, and empty results. ChangesShuttle arrival-time handling
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to The shuttle and commuting bus remaining-time response now excludes uncalculable entries before ordering, preventing failures when valid and null arrival times are mixed while preserving valid ordered results. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
| public List<BusRemainTime> getShuttleBusRemainTimes(BusType busType, BusStation depart, BusStation arrival) { | ||
| List<Route> routes = getShuttleRoutesByBusType(busType); | ||
|
|
||
| // 시간 정렬은 BusService에서 계산할 수 없는 항목을 제외한 뒤 수행한다. |
There was a problem hiding this comment.
BusService 이외의 서비스로직에서 이 메서드를 사용할 수도 있을것 같은데요
이 주석은 너무 이슈 하나에만 집중된 내용같다는 생각이 드네요. 어떻게생각하시나요?
There was a problem hiding this comment.
BusService 외 다른 서비스에서 사용할 수 있다는 것까지는 생각하지 못했습니다.
도착 시간이 null인 항목을 먼저 제외하도록 하여 발견한 문제를 해결하고, 정렬까지 이 메서드에서 하도록 수정하는 방향으로 진행해보겠습니다.
🔍 개요
GET /bus에서 정상 도착 시각과 null 시각이 함께 선택되면 셔틀 서비스의 선행 정렬이BusRemainTime.compareTo():85에서 NPE를 발생시킵니다. 기존 응답 변환의 무효 시간 필터 → 정렬 순서를 사용하여 이번 HTTP 500을 차단합니다.🚀 주요 변경 내용
ShuttleBusService.getShuttleBusRemainTimes()의.sorted()를 제거합니다..distinct()는 유지하며, 정렬은BusService.toResponse()가 남은 시간을 계산할 수 없는 항목을 제외한 뒤 수행합니다.Route → ShuttleBusService → BusService경로를 사용하는 회귀 테스트 7개를 추가합니다. 저장소와 외부 서비스 의존성만 mock 처리합니다.14:25와 중복 터미널이 있는 주말 하교 노선의 null 시각이 함께 선택되는 조건💬 참고 사항
BusRemainTime.java:85로 실패했고, 수정 후 전부 통과했습니다../gradlew test --tests 'in.koreatech.koin.unit.domain.bus.*' bootJar --console=plain성공. 버스 테스트 25개, 실패/오류/건너뜀 0개이며 애플리케이션 JAR 생성도 성공했습니다.git diff --check도 통과했습니다. 로컬 JDK는 20.0.2이며 GitHub CI는 저장소 설정대로 JDK 17에서 전체 build를 실행합니다.Route의 방향/운행 구간 판정 및 중복 정류장 선택 불일치는 남습니다. 계산할 수 없는 항목을 제외하는 기존 동작을 유지하며, 누락될 수 있는 버스의 정확한 경로와 출발 시각까지 교정하지는 않습니다. 실제 하교 시간표의 방향 반전으로 시간 순서가 거꾸로인 경로가 통과하는 문제도 #2409에 후속 과제로 기록했습니다.✅ Checklist (완료 조건)
Summary by CodeRabbit
Bug Fixes
Tests