fix: EgovBatchException 이 전달받은 원인 예외를 즉시 버리는 문제 수정 - #307
Open
masiljangajji wants to merge 1 commit into
Open
Conversation
원인 예외를 받는 생성자가 해당 값을 필드에 대입한 직후 null 로 덮어쓴다. 호출 측에서 getWrappedException() 으로 원인을 되찾을 수 없다. - 불필요한 null 대입 한 줄을 제거한다 - 원인 예외 보관 여부와 메시지 조회 동작을 확인하는 테스트를 추가한다
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
소스를 수정한 사유가 무엇인지 체크해 주세요. Please check the reason you modified the source. ([X] X는 대문자여야 합니다.)
수정된 소스 내용 Modified source
검토자를 위해 수정된 소스 내용을 설명해 주세요. Please describe the modified source for reviewers.
한 줄 요약
EgovBatchException의 원인 예외를 받는 생성자가 전달받은 값을 필드에 대입한 직후null로 덮어씁니다. 호출 측이getWrappedException()으로 원인을 되찾을 수 없습니다.1. 현재 코드
세 번째 줄에서 인자를 필드에 넣고, 다섯 번째 줄에서 다시
null로 만듭니다.2. 어떻게 생겼는가
같은 클래스의 다른 생성자 두 개는 원인 예외를 받지 않으므로
null대입이 정상입니다.원인 예외를 받는 생성자를 만들 때 위 코드를 바탕으로 작성하면서 마지막 줄을 함께 옮긴 형태로 보입니다.
3. 왜 문제가 되는가
wrappedException은 부모 클래스에 있고 공개 접근자를 통해 외부에서 읽습니다.따라서 이 생성자로 만든 예외는 전달한 원인 예외를 되찾을 수 없습니다.
배치 작업이 실패했을 때 근본 원인을 추적하기 위해 원인 예외를 넘기는 것이 이 생성자의 목적이고, Javadoc 도
@param wrappedException 에러객체로 그 의도를 명시하고 있습니다.이 저장소 안에서
EgovBatchException을 생성하는 곳은CustomerCreditIncreaseProcessor한 곳이고, 거기서는 원인 예외를 넘기지 않는 형태(EgovBatchException(dataSource, messageKey))를 쓰고 있어 현재 동작에는 영향이 없습니다. 다만 원인 예외를 받는 생성자도public이므로, 표준프레임워크로 배치 애플리케이션을 작성하는 쪽에서 호출하는 API 입니다.4. 수정 내용
불필요한
null대입 한 줄을 제거했습니다.this.wrappedException = wrappedException; this.messageParameters = null; - this.wrappedException = null; }5. 영향 범위
EgovBatchException.java한 줄 삭제입니다getExceptionMessageSelect), 메시지키·메시지 파라미터 처리는 그대로입니다null입니다JUnit 테스트 JUnit tests
테스트를 완료하셨으면 다음 항목에 [대문자X]로 표시해 주세요. When you're done testing, check the following items.
JDK 17 환경에서
org.egovframe.rte.bat.core모듈을 대상으로 확인했습니다.main)mvn clean test기존 61건에 이 PR 에서 3건을 더했습니다. 회귀는 없습니다.
추가한 테스트
EgovBatchExceptionWrappedExceptionTest를 추가했습니다. 세 가지를 확인합니다.생성자가
JdbcTemplate으로BATCH_EXCEPTION_MESSAGE를 조회하므로DataSource가 필요합니다. 별도 설비를 추가하지 않고 이 모듈의 기존 테스트 스키마를 재사용했습니다.testdb.sql에BATCH_EXCEPTION_MESSAGE테이블과EGOVBATCH000001행이 이미 정의되어 있어 그대로 사용했습니다.수정 전 실패 확인
수정 없이 테스트만
main에 적용해 실행한 결과입니다.나머지 두 건은 수정 전에도 통과합니다. 수정으로 동작이 바뀌는 지점이 첫 번째 한 건임을 확인했습니다.
재현 절차
외부 DB 가 필요 없습니다. 내장 HSQLDB 로 동작합니다.
테스트 브라우저 Test Browser
테스트를 진행한 브라우저를 선택해 주세요. Please select the browser(s) you ran the test on. (다중 선택 가능 you can select multiple) [X] X는 대문자여야 합니다.
배치 실행환경의 예외 클래스 변경이라 화면이나 브라우저와 무관합니다. 그래서 별도로 선택하지 않았습니다.
테스트 스크린샷 또는 캡처 영상 Test screenshots or captured video
테스트 전과 후의 스크린샷 또는 캡처 영상을 이곳에 첨부해 주세요. Please attach screenshots or video captures of your before and after tests here.
화면 변경이 없어 첨부하지 않았습니다. 위 재현 절차의 테스트 결과로 확인하실 수 있습니다.