fix: PaginationInfo 0 분모 나눗셈 예외(/ by zero) 방지 가드 추가#253
Open
z3rotig4r wants to merge 1 commit into
Open
Conversation
recordCountPerPage 또는 pageSize 가 미설정(기본값 0)일 때 getTotalPageCount(), getFirstPageNoOnPageList() 에서 발생하던 '/ by zero' ArithmeticException 을 안전 폴백으로 회피한다. totalRecordCount 가 0 이면 페이지 수는 0 으로 반환한다. 정상 입력에 대한 계산 결과는 변경되지 않는다. - getTotalPageCount(): recordCountPerPage<=0 또는 totalRecordCount<=0 이면 0 반환 - getFirstPageNoOnPageList(): pageSize<=0 이면 1 반환 - PaginationTest 에 경계값(0 분모)·회귀 테스트 추가
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.
변경 이유
PaginationInfo.getTotalPageCount()는((getTotalRecordCount() - 1) / getRecordCountPerPage()) + 1을 계산합니다(PaginationInfo.java:122부근).recordCountPerPage는 plainint필드이며 public 세터로 외부에서 설정되는데, 미설정 시 기본값이0이라 분모가0이 되어 정수 나눗셈에서ArithmeticException: / by zero가 발생합니다.getFirstPageNoOnPageList()도 동일하게((getCurrentPageNo() - 1) / getPageSize()) * getPageSize() + 1에서pageSize == 0이면 같은 예외가 발생합니다(PaginationInfo.java:139부근).필드가 plain
int이고 public 세터로 노출되어 있어, 세터를 호출하지 않은 인스턴스가 그대로 사용되는 미설정 상태에 도달 가능합니다.변경 내용
getTotalPageCount():recordCountPerPage <= 0또는totalRecordCount <= 0이면totalPageCount = 0을 반환하도록 가드를 추가했습니다(페이지 없음).getFirstPageNoOnPageList():pageSize <= 0이면firstPageNoOnPageList = 1을 반환하도록 가드를 추가했습니다(첫 페이지).테스트 방법
PaginationTest에 버그 재현 및 회귀 테스트를 추가했습니다.recordCountPerPage == 0에서getTotalPageCount()가,pageSize == 0에서getFirstPageNoOnPageList()가 각각ArithmeticException을 던지는 것을 재현합니다.영향 범위
org.egovframe.rte.ptl.mvc.tags.ui.pagination.PaginationInfo의getTotalPageCount,getFirstPageNoOnPageList.