fix: getFullAge 가 외국인등록번호 세대코드 5~8 을 인식하지 못해 0 을 돌려주던 문제 수정 - #415
Open
comghost wants to merge 1 commit into
Open
fix: getFullAge 가 외국인등록번호 세대코드 5~8 을 인식하지 못해 0 을 돌려주던 문제 수정#415comghost wants to merge 1 commit into
comghost wants to merge 1 commit into
Conversation
EgovDateUtil.getFullAge(socialNo, keyDate) 는 7번째 자리(세대코드)로 출생 세기를 정하는데 0·9, 1·2, 3·4 만 알고 외국인등록번호의 5·6(1900년대)과 7·8(2000년대)은 모른다. 그래서 외국인의 만 나이는 언제나 0 이 되고, 잘못된 입력(null·짧은 문자열· 숫자 아닌 세대코드)도 똑같이 0 이라 호출자는 "0세"와 "계산 실패"를 구분할 수 없다. - 세대코드 5·6 은 1900년대, 7·8 은 2000년대로 계산한다 - null 이거나 짧은 인자, 0~9 밖의 세대코드, 숫자가 아닌 자리는 0 대신 IllegalArgumentException 으로 알린다. getCurrentFullAge 도 같은 규칙을 따른다 - 정상 입력의 계산식(생일 경과 여부에 따른 -1)은 그대로다 EgovDateUtilTest 갱신 — 0 반환을 고정하던 characterization 테스트를 세대코드 5~8 의 정상 계산과 잘못된 입력의 예외 단언으로 바꾸고, getCurrentFullAge 는 현재 일자로 getFullAge 에 위임한 값과 같은지 확인한다.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
수정 사유 Reason for modification
수정된 소스 내용 Modified source
문제
EgovDateUtil.getFullAge(socialNo, keyDate)는 7번째 자리(세대코드)로 출생 세기를 정하는데 0·9, 1·2, 3·4 만 알고외국인등록번호의 5·6(1900년대)·7·8(2000년대)은 모릅니다. 그래서 외국인의 만 나이는 언제나 0 입니다.
같은 이유로 잘못된 입력(
null, 짧은 문자열, 숫자가 아닌 세대코드)도 전부 0 을 돌려줘, 호출자는 "0세"와 "계산 실패"를구분할 수 없습니다. #251 이 이 0 반환을 characterization 테스트로 고정해 두어(현재 동작의 명세화) 의도된 동작처럼
보이지만, 외국인등록번호를 처리하는 사업에서는 잘못된 나이가 조용히 저장되는 결함입니다. 이 PR 은 그 테스트를 새 계약으로 바꿉니다.
수정
socialNo/keyDate가null이거나 짧음IllegalArgumentException-포함 형식 등)IllegalArgumentExceptionNumberFormatExceptionIllegalArgumentException의 하위)getCurrentFullAge(socialNo)는getFullAge에 위임하므로 같은 규칙을 따릅니다.호환성
예외입니다. 0 을 "계산 불가" 신호로 쓰던 호출자가 있다면
IllegalArgumentException을 잡도록 바꿔야 하므로 릴리스노트에 계약 변경으로 적어 주시면 좋겠습니다.
770101-1234567)은 이전에도 0 을 돌려줬을 뿐 지원된 적이 없으며, 이제는 예외로 드러납니다.JUnit 테스트 JUnit tests
EgovDateUtilTest갱신(0 반환 characterization 2건 → 외국인 코드 4케이스·예외 6케이스·위임 검증),fdl.string모듈 전건 통과.Tests run: 62, Failures: 0, Errors: 0, Skipped: 0Tests run: 62, Failures: 0, Errors: 0, Skipped: 0keyDatenull ·socialNonull · 6자리 · 구분자 포함 · 세대코드 자리에 영문자 · 생년월일 자리에 영문자 → 전부IllegalArgumentExceptiongetCurrentFullAge가 현재 일자로getFullAge에 넘긴 값과 같고, 1980년생 외국인은 40세 이상수동 확인: 현재
main(cc2b332) 위에서fdl.string모듈 빌드·테스트가 통과함을 Windows 와 Linux 에서 확인했습니다.테스트 브라우저 Test Browser
해당 없음 — 라이브러리 내부 수정입니다.
테스트 스크린샷 또는 캡처 영상 Test screenshots or captured video
해당 없음 — 위 JUnit 테스트 결과로 갈음합니다.
base:
eGovFramework:main@cc2b332(2026-09-10 fetch 기준, #366~#379 머지 후) · 단일 커밋