fix: AbstractXMLUtility XML 저장 시 OutputStream 자원 누수 수정#268
Open
z3rotig4r wants to merge 1 commit into
Open
Conversation
AbstractXMLUtility의 XML 저장 로직은 new StreamResult(Files.newOutputStream(...))로 생성한 OutputStream을 닫지 않는다. 이 저장 경로는 XML 변경 공개 API 6곳에서 호출되며, 반복 저장하거나 transform()이 예외를 던지면 파일 디스크립터가 누적되고 Windows에서는 파일 잠금이 지속될 수 있다. OutputStream을 try-with-resources로 관리해 transform() 성공·예외와 무관하게 항상 닫히도록 수정한다. StreamResult는 스트림을 감싸는 홀더일 뿐이라 별도로 닫지 않으며, transform() 예외는 기존과 동일하게 전파된다. 테스트: 동일 경로 반복 저장 후 결과가 매번 유효한 XML로 재파싱되는지 확인.
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.
배경
AbstractXMLUtility의 XML 저장 로직은new StreamResult(Files.newOutputStream(...))로 생성한OutputStream을 닫지 않습니다. 이 저장 경로는 XML 변경 공개 API 6곳에서 호출되며, 반복 저장하거나transform()이 예외를 던지면 파일 디스크립터가 누적되고 Windows에서는 파일 잠금이 지속될 수 있습니다.변경 내용
OutputStream을 try-with-resources로 관리해transform()의 성공·예외와 무관하게 항상 닫히도록 수정합니다.StreamResult는 스트림을 감싸는 홀더일 뿐이므로 별도로 닫지 않으며,transform()예외는 기존과 동일하게 전파됩니다.테스트
동일 경로로 반복 저장한 뒤 결과가 매번 유효한(well-formed) XML로 재파싱되는지 확인하는 특성 테스트를 추가했습니다. 파일 디스크립터 수 관측은 운영체제에 의존하므로 테스트에 포함하지 않았고, 스트림 종료는 try-with-resources로 보장됩니다.
영향
저장 결과는 동일하며, 반복 저장·예외 상황에서 스트림이 확실히 닫힙니다.