Skip to content

fix(rte.rdt): pom 버전 프로퍼티 미해결 시 NullPointerException 수정 - #139

Open
EricSeokgon wants to merge 1 commit into
eGovFramework:mainfrom
EricSeokgon:patch-1
Open

fix(rte.rdt): pom 버전 프로퍼티 미해결 시 NullPointerException 수정#139
EricSeokgon wants to merge 1 commit into
eGovFramework:mainfrom
EricSeokgon:patch-1

Conversation

@EricSeokgon

Copy link
Copy Markdown
Contributor

수정 사유 (Reason for modification)

  • 버그수정 (Bug fixes)

문제 (재현)

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.setDependenciesnew Dependency(e, properties)new Version(e, properties)setContent. <properties> 블록이 있는 pom 이면 properties 가 non-null 로 전달되므로 흔한 표기에서 그대로 발생합니다.

수정 내용

if (properties.getValue(version) != null) 블록에 중괄호를 추가하여, 프로퍼티가 해결될 때만 propertyVersion/realVersion 을 갱신하도록 했습니다. 미해결 시에는 상단에서 설정한 기본값(realVersion = getContent() = 원본 ${...} 문자열, propertyVersion = false)이 그대로 유지됩니다.

-				if (properties.getValue(version) != null)
-					setPropertyVersion(true);
-					realVersion = properties.getValue(version).toString();
+				if (properties.getValue(version) != null) {
+					setPropertyVersion(true);
+					realVersion = properties.getValue(version).toString();
+				}

검증 (실측)

저장소의 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() = true
    • 4.3.0 (리터럴, 회귀): getRealVersion() = "4.3.0", isPropertyVersion() = false

Version.setContent()의 if (properties.getValue(version) != null) 에 중괄호가 없어 realVersion 대입이 무조건 실행됨. <properties>에 정의되지 않은 프로퍼티(예: 내장 ${project.version})를 참조하는 dependency 버전에서 null.toString() NPE로 pom 파싱이 중단됨. 중괄호를 추가해 프로퍼티 해결 시에만 갱신하고 미해결 시 원본 문자열을 유지.
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