[fix] EgovMyBatisBatchItemWriter 공유 변수 주입 기능 복구 (이슈 #239)#273
Open
dasomel wants to merge 1 commit into
Open
Conversation
write(Chunk)에서 item과 공유 변수(resourceVariable/jobVariable/stepVariable)를 병합한 Map을 만들었지만 정작 super.write() 호출 시 원본 chunk를 그대로 넘겨 병합 결과가 전혀 사용되지 않던 문제를 수정. MyBatisBatchItemWriter가 제공하는 itemToParameterConverter 확장 지점을 사용해 item 단위로 파라미터를 변환하도록 변경. 공유 변수가 하나도 설정되지 않으면 item을 그대로 반환해 기존 동작을 그대로 보존하고, 값이 충돌하면 item 프로퍼티가 공유 변수보다 우선하도록 했다.
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.
변경 사유
이슈 #239에서 지적된 대로,
EgovMyBatisBatchItemWriter에setResourceVariable/setJobVariable/setStepVariable로 공유 변수를 설정해도 MyBatis statement 파라미터에 반영되지 않는 문제가 있었습니다.write(Chunk)가 item과 공유 변수를 병합한 Map을 만들면서도 실제로는super.write()에 원본 chunk를 그대로 넘겨 병합 결과를 사용하지 않고 있었습니다. reader 쪽(EgovMyBatisPagingItemReader)은 동일 기능이 정상 동작해 reader/writer 간 동작 비대칭이 있었습니다.변경 내용
write(Chunk)오버라이드를 제거하고,MyBatisBatchItemWriter가 제공하는setItemToParameterConverter(Converter<T, ?>)확장 지점을 사용하도록 변경했습니다.EgovMyBatisBatchItemWriterTest를 신설해 (1) 공유 변수 미설정 시 기존 동작 보존, (2) 공유 변수 병합, (3) item 프로퍼티 우선순위, (4) step > job > resource 우선순위를 검증합니다.테스트 방법 / 영향 범위
Batch/org.egovframe.rte.bat.core모듈에서mvn test실행, 18개 테스트(신규 4개 포함) 전부 통과했습니다. 공유 변수를 사용하지 않는 기존 사용자는 동작 변화가 없고, 공유 변수를 설정했던 경우는 (원래 의도대로) 값이 실제로 반영되도록 동작이 바뀝니다 — 이는 이슈에서 요구한 기능 복구 자체입니다.