Skip to content

fix: convert2CamelCase 빈/null 입력 예외 방지#246

Open
z3rotig4r wants to merge 1 commit into
eGovFramework:mainfrom
z3rotig4r:fix/camelutil-empty-input-guard
Open

fix: convert2CamelCase 빈/null 입력 예외 방지#246
z3rotig4r wants to merge 1 commit into
eGovFramework:mainfrom
z3rotig4r:fix/camelutil-empty-input-guard

Conversation

@z3rotig4r

Copy link
Copy Markdown
Contributor

문제

언더스코어 표기를 카멜 표기로 바꾸는 두 유틸이 빈 문자열·null 입력에서 예외를 던집니다.

  • org.egovframe.rte.psl.dataaccess.util.CamelUtil.convert2CamelCase
  • org.egovframe.rte.fdl.security.userdetails.util.CamelCaseUtil.convert2CamelCase
// CamelUtil
if (underScore.indexOf('_') < 0 && Character.isLowerCase(underScore.charAt(0))) {

빈 문자열이면 charAt(0)에서 StringIndexOutOfBoundsException이, null이면 indexOf 호출(CamelCaseUtilisSkipCase 내부)에서 NullPointerException이 발생합니다.

특히 CamelUtilEgovMap.put모든 맵 키마다 호출합니다.

public Object put(Object key, Object value) {
    return super.put(CamelUtil.convert2CamelCase((String) key), value);
}

따라서 키가 null이거나 빈 문자열이면 MyBatis EgovMap resultType 처리 경로에서 예외로 이어질 수 있습니다.

수정

두 유틸 모두 진입부에 null/빈 문자열 가드를 추가해 입력을 그대로 반환하도록 했습니다.

if (underScore == null || underScore.isEmpty()) {
    return underScore;
}

기존 변환 동작은 그대로 유지됩니다.

검증

각 테스트 클래스에 빈 문자열·null 회귀 테스트를 추가했습니다.

mvn -pl Persistence/org.egovframe.rte.psl.dataaccess -am test -Dtest=CamelUtilTest
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0

mvn -pl Foundation/org.egovframe.rte.fdl.security -am test -Dtest=CamelCaseUtilTest
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0

CamelUtil.convert2CamelCase와 CamelCaseUtil.convert2CamelCase는
입력이 빈 문자열이면 charAt(0)에서 StringIndexOutOfBoundsException이,
null이면 NullPointerException이 발생합니다.

CamelUtil은 EgovMap.put이 모든 맵 키마다 호출하므로(키가 빈 문자열이거나
null인 경우) MyBatis EgovMap resultType 처리 경로에서 예외로 이어질 수
있습니다.

두 유틸 모두 진입부에 null/빈 문자열 가드를 추가해 입력을 그대로
반환하도록 했습니다. 각 테스트 클래스에 빈 문자열·null 회귀 테스트를
추가했습니다.
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