fix(filehandling): EgovFileUtil.readFile 빈 파일 NoSuchElementException 방지#257
Open
z3rotig4r wants to merge 1 commit into
Open
fix(filehandling): EgovFileUtil.readFile 빈 파일 NoSuchElementException 방지#257z3rotig4r wants to merge 1 commit into
z3rotig4r wants to merge 1 commit into
Conversation
readFile(File, encoding)의 조인 루프가 hasNext() 검사 없이 it.next()를 먼저
호출해, 빈 파일(빈 라인 리스트)에서 NoSuchElementException이 미포착 전파됐다.
표준 hasNext() 가드 루프로 교체해 빈 파일은 빈 문자열을 반환한다. 죽은 코드
sb.append("")(항상 no-op) 제거로 비어있지 않은 입력의 출력은 불변이다.
테스트: 빈 파일/여러 줄 파일 읽기 2건 추가.
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.
문제
EgovFileUtil.readFile(File, encoding)의 라인 결합 루프가hasNext()검사 없이it.next()를 먼저 호출한다.내용이 없는 파일은 라인 리스트가 비어 있어 첫
it.next()에서NoSuchElementException이 미포착 전파된다. 기대값은 빈 문자열이다.수정
표준
hasNext()가드 루프로 교체했다.sb.append("")는 어떤 입력에서도 no-op이므로, 비어 있지 않은 단일/여러 줄 입력의 출력은 종전과 바이트 단위로 동일하다. 라인 구분자 처리 의미는 변경하지 않았다(readLines계열이 구분자를 제거하는 기존 동작 유지).테스트
FilehandlingServiceTest에 2건 추가, 모듈 25건 통과.testReadEmptyFile: 빈 파일 →""반환testReadMultiLineFile: 여러 줄 입력의 결합 결과가 종전과 동일함을 고정(회귀 가드)