Skip to content

fix: EgovIndexFileWriter에 setResourceLoader 추가로 classpath 리소스 경로 NPE 방지#266

Open
z3rotig4r wants to merge 1 commit into
eGovFramework:mainfrom
z3rotig4r:fix/batch-indexfilewriter-resourceloader
Open

fix: EgovIndexFileWriter에 setResourceLoader 추가로 classpath 리소스 경로 NPE 방지#266
z3rotig4r wants to merge 1 commit into
eGovFramework:mainfrom
z3rotig4r:fix/batch-indexfilewriter-resourceloader

Conversation

@z3rotig4r

Copy link
Copy Markdown
Contributor

배경

EgovIndexFileWriter는 classpath 기반 indexResource를 해석할 때 configureWriterIndexResouce()에서 resourceLoader.getResource(...)를 호출합니다. 그러나 이 클래스에는 resourceLoader 필드를 주입할 수 있는 경로가 없습니다. ResourceLoaderAware를 구현하지도 않고 세터도 없어 필드가 항상 null로 남고, classpath 경로를 사용하면 NullPointerException이 발생합니다.

형제 클래스 EgovIndexFileReader는 동일한 목적의 setResourceLoader(ResourceLoader)를 이미 제공합니다. Writer에만 이 주입 경로가 빠져 있습니다.

변경 내용

EgovIndexFileReader와 동일하게 EgovIndexFileWritersetResourceLoader(ResourceLoader)를 추가합니다. 파일시스템 경로 분기는 ResourceLoader를 사용하지 않으므로 영향이 없고, classpath 경로에서만 주입된 로더로 정상 해석됩니다.

테스트

  • ResourceLoader 미주입 시 classpath indexResource 해석에서 NullPointerException이 발생함을 확인(버그 재현).
  • ResourceLoader 주입 후 classpath 경로가 정상 해석되어 resource가 설정됨을 확인.
  • 세터가 Reader와 동일한 공개 메서드로 제공됨을 확인.

영향

기존 코드를 수정하지 않고 setter를 추가하기만 하는 변경입니다. 기존 파일시스템 경로 사용자는 영향받지 않으며, classpath 경로 사용 시에만 새 주입 경로가 동작합니다.

EgovIndexFileWriter는 classpath 기반 indexResource를 해석할 때
configureWriterIndexResouce()에서 resourceLoader.getResource()를 호출하지만,
이 필드를 주입할 경로가 없다. ResourceLoaderAware를 구현하지도 않고 세터도 없어
필드가 항상 null로 남고, classpath 경로 사용 시 NullPointerException이 발생한다.

형제 클래스 EgovIndexFileReader는 동일 목적의 setResourceLoader(ResourceLoader)를
이미 제공한다. Writer에도 동일한 세터를 추가해 classpath 경로가 정상 해석되도록 한다.
파일시스템 경로 분기는 ResourceLoader를 사용하지 않으므로 영향이 없다.

테스트: 미주입 시 NPE 재현, 주입 후 classpath 경로 정상 해석(resource 설정), 세터 존재 확인.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant