fix(bdev.batch): Decision의 Next 행을 편집할 때 발생하는 ArrayIndexOutOfBoundsException 수정 - #142
Open
EricSeokgon wants to merge 1 commit into
Open
fix(bdev.batch): Decision의 Next 행을 편집할 때 발생하는 ArrayIndexOutOfBoundsException 수정#142EricSeokgon wants to merge 1 commit into
EricSeokgon wants to merge 1 commit into
Conversation
getAvailableNextVoFromTable()은 편집 모드에서 NextVo[items.length - 1]을 할당하면서 복사는 원본 인덱스 i로 수행해, 선택한 행이 마지막이 아니면 ArrayIndexOutOfBoundsException이 발생한다. 같은 클래스의 getStepAndDecisionNameList()와 동일하게 쓰기 전용 카운터를 분리한다.
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)
문제 (재현)
DecisionInfoContentsConstructor.getAvailableNextVoFromTable()은 편집 모드(선택된NextVo가 있는 경우)에서 결과 배열을items.length - 1크기로 만들면서, 복사할 때는 원본 인덱스i를 그대로 씁니다.건너뛴 행이 마지막 행이 아니면
i가items.length - 1까지 올라가면서 배열 끝을 넘어 써, ArrayIndexOutOfBoundsException 이 발생합니다. Decision 편집 화면의 Next 테이블에서 마지막이 아닌 행을 선택해 Edit 하면 재현됩니다.선택 행이 마지막인 경우에는 인덱스가 배열 크기를 넘지 않아 정상 동작하기 때문에, 이 결함이 지금까지 드러나지 않은 것으로 보입니다.
수정 내용
같은 클래스의
getStepAndDecisionNameList()가 동일한 "선택 항목만 제외하고 복사" 처리를 쓰기 전용 카운터j로 올바르게 구현하고 있어, 그 방식에 맞췄습니다.if (items.length > 0) { + int j = 0; + for (int i = 0; i < items.length; i++) { NextVo nextVo = (NextVo) items[i].getData(); if (!isAdd && selectedNextVo.compare(nextVo)) { continue; } else { - nextVos[i] = (NextVo) items[i].getData(); + nextVos[j] = (NextVo) items[i].getData(); + j++; } } }검증 (실측)
해당 메서드의 로직을 그대로 옮긴 standalone 하네스로 수정 전/후를 비교했습니다(
TableItem.getData()는NextVo[]로 대체, 나머지는 동일).[FAILED->step2][COMPLETED->step1, *->step3][COMPLETED->step1][]현재 정상 동작하는 3개 케이스는 결과가 완전히 같고, 예외가 나던 2개 케이스만 정상 반환으로 바뀝니다.