fix(batch): EgovPartitionFlatFileItemWriter의 Spring Batch 5 계약 복구 - #291
Open
ParkJunGyu26 wants to merge 1 commit into
Open
fix(batch): EgovPartitionFlatFileItemWriter의 Spring Batch 5 계약 복구#291ParkJunGyu26 wants to merge 1 commit into
ParkJunGyu26 wants to merge 1 commit into
Conversation
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
수정된 소스 내용 Modified source
공식 문서 참고
현재 Batch 모듈의 Spring Batch 의존성은
5.2.3입니다.Spring Batch 5.2.3 공식 API 문서 기준으로
ItemWriter의write메서드는List가 아니라Chunk<? extends T>를 인자로 받습니다.ItemWriterAPI:write(@NonNull Chunk<? extends T> chunk)또한
ResourceAwareItemWriterItemStream은WritableResource에 출력하는ItemStreamWriter계약을 제공하며,setResource(WritableResource resource)메서드를 정의합니다.ResourceAwareItemWriterItemStreamAPI:setResource(WritableResource resource)따라서 본 PR은
EgovPartitionFlatFileItemWriter가 Spring Batch 5의 writer/resource 계약에 맞게 실제 리소스를 설정하고,Chunk기반 쓰기 호출을 기존 파일 쓰기 로직으로 위임하도록 수정한 것입니다.AS-IS
Spring Batch 5에서
ItemWriter#write(List)가ItemWriter#write(Chunk)로 변경되었으나,EgovPartitionFlatFileItemWriter의 Spring Batch 5 인터페이스 구현이 비어 있습니다.이로 인해 다음 문제가 발생합니다.
WritableResource인터페이스를 통해 출력 리소스를 설정하면 내부resource가null로 남아open()에서The resource must be set예외가 발생합니다.SimpleChunkProcessor가 호출하는write(Chunk)가 아무 작업도 하지 않아Step이 전달한 항목이 파일에 기록되지 않습니다.
write(List)의 실제 파일 쓰기 로직은 남아 있지만 Spring Batch 5의 호출 경로와연결되지 않습니다.
Spring Batch 5 마이그레이션 가이드:
https://github.com/spring-projects/spring-batch/wiki/Spring-Batch-5.0-Migration-Guide
TO-BE
setResource(WritableResource)를 기존setResource(Resource)에 위임합니다.write(Chunk)와 기존write(List)가 동일한 privatedoWrite(List)구현을 사용합니다.영향 범위 및 호환성
write(List)공개 메서드를 유지합니다.EgovPartitionFlatFileItemWriter에 한정됩니다.JUnit 테스트 JUnit tests
수정 전 재현
origin/main에 동일한 회귀 테스트를 실행한 결과입니다.수정 후 회귀 테스트
Batch 모듈 전체 검증
JAR, sources JAR 및 Javadoc JAR 생성도 완료되었습니다.
테스트 브라우저 Test Browser
테스트 스크린샷 또는 캡처 영상 Test screenshots or captured video
AS-IS
Spring Batch 5 인터페이스 경로에서 동일한 회귀 테스트 2개가 실패합니다.
TO-BE
동일한 Java 17 환경에서 같은 회귀 테스트 2개가 모두 통과합니다.