fix(rte.rdt): pom 버전 프로퍼티 미해결 시 NullPointerException 수정 - #139
Open
EricSeokgon wants to merge 1 commit into
Open
Conversation
Version.setContent()의 if (properties.getValue(version) != null) 에 중괄호가 없어 realVersion 대입이 무조건 실행됨. <properties>에 정의되지 않은 프로퍼티(예: 내장 ${project.version})를 참조하는 dependency 버전에서 null.toString() NPE로 pom 파싱이 중단됨. 중괄호를 추가해 프로퍼티 해결 시에만 갱신하고 미해결 시 원본 문자열을 유지.
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)
문제 (재현)
egovframework.rte.rdt.pom.unit.Version.setContent()에서if (properties.getValue(version) != null)에 중괄호가 없어, 바로 아래realVersion = properties.getValue(version).toString();이 조건과 무관하게 항상 실행됩니다. (들여쓰기상 두 줄 모두 if 안처럼 보이지만 실제로는setPropertyVersion(true);한 줄만 가드됩니다.)따라서 dependency 의
<version>이 해당 pom 의<properties>에 정의되지 않은 프로퍼티를 참조하면properties.getValue(version)이null을 반환하고null.toString()에서 NullPointerException 이 발생해 pom 파싱이 중단됩니다. 대표적으로 Maven 내장 프로퍼티${project.version}(또는 부모 pom 에서 상속되는 버전 프로퍼티)는 로컬<properties>에 존재하지 않으므로 바로 재현됩니다.호출 경로:
PomObject.setDependencies→new Dependency(e, properties)→new Version(e, properties)→setContent.<properties>블록이 있는 pom 이면properties가 non-null 로 전달되므로 흔한 표기에서 그대로 발생합니다.수정 내용
if (properties.getValue(version) != null)블록에 중괄호를 추가하여, 프로퍼티가 해결될 때만propertyVersion/realVersion을 갱신하도록 했습니다. 미해결 시에는 상단에서 설정한 기본값(realVersion = getContent()= 원본${...}문자열,propertyVersion = false)이 그대로 유지됩니다.검증 (실측)
저장소의
egovframework.rte.rdt/lib/jdom.jar로 실제 소스(Version/PomString/PomElement/PomMap/StringHelper)를 컴파일하여 확인했습니다.<version>${project.version}</version>+project.version미정의 → NullPointerException${project.version}(미해결): 예외 없음,getRealVersion()="${project.version}",isPropertyVersion()=false${egov.rte.version}(해결, 회귀):getRealVersion()="4.3.0",isPropertyVersion()=true4.3.0(리터럴, 회귀):getRealVersion()="4.3.0",isPropertyVersion()=false