fix: EgovReflectionSupport의 setter/getter 이름 생성이 로케일에 따라 깨져 NPE가 나는 문제 수정 - #329
Open
wantaekchoi wants to merge 1 commit into
Open
Conversation
…제 수정 VO 필드명으로 접근자 이름을 만들 때 첫 글자를 toUpperCase()로 올리는데, 인자 없는 toUpperCase()는 JVM 기본 로케일을 따른다. 터키어·아제르바이잔어 로케일에서는 "id".substring(0, 1).toUpperCase()가 점 있는 'İ'(U+0130)가 되어 "setİd"/"getİd"를 찾게 되고, 실제 메서드명 setId/getId와 일치하지 않는다. retrieveMethod는 못 찾으면 null을 돌려주고 그 null이 그대로 methodMap에 담긴다. 이후 invokeSetterMethod와 invokeGettterMethod는 map에서 꺼낸 Method로 바로 invoke를 호출하고 catch도 IllegalAccessException/InvocationTargetException만 잡으므로, i로 시작하는 필드가 하나라도 있으면 NullPointerException으로 죽는다. java.lang.NullPointerException: Cannot invoke "java.lang.reflect.Method.invoke(...)" because the return value of "java.util.HashMap.get(Object)" is null 두 곳(generateSetterMethodMap, generateGetterMethodMap)에 Locale.ROOT를 명시해 기본 로케일과 무관하게 ASCII 규칙으로 변환하도록 했다. 같은 결함 클래스를 Locale.ROOT로 고친 선례가 이 저장소에 있다 — DefaultMapUserDetailsMapping의 컬럼명 소문자화(eGovFramework#321, 59e4d31).
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
수정된 소스 내용 Modified source
EgovReflectionSupport는 VO 필드명으로 접근자 이름을 만들 때 첫 글자를toUpperCase()로 올립니다. 인자 없는toUpperCase()는 JVM 기본 로케일을 따르므로, 터키어·아제르바이잔어 로케일에서"id".substring(0, 1).toUpperCase()는 점 있는İ(U+0130)가 되어setİd/getİd를 찾게 되고 실제 메서드명setId/getId와 일치하지 않습니다.retrieveMethod는 못 찾으면null을 돌려주고 그null이 그대로methodMap에 담깁니다.invokeSetterMethod와invokeGettterMethod는 맵에서 꺼낸Method로 바로invoke를 호출하고 catch도IllegalAccessException/InvocationTargetException만 잡으므로,i로 시작하는 필드가 하나라도 있으면NullPointerException으로 죽습니다.AS-IS (
generateSetterMethodMap,generateGetterMethodMap두 곳)TO-BE
같은 결함 클래스를
Locale.ROOT로 고친 선례가 이 저장소에 있습니다 —DefaultMapUserDetailsMapping의 컬럼명 소문자화(#321).영향 범위
ASCII 필드명은 기본 로케일이 무엇이든 결과가 같습니다. 바뀌는 것은 터키어 계열 로케일에서
i로 시작하는 필드뿐입니다.JUnit 테스트 JUnit tests
EgovReflectionSupportLocaleTest2건을 추가했습니다. 기본 로케일을tr-TR로 바꾼 상태에서 setter/getter 양쪽 경로를 각각 확인하고, 영어 로케일 대조군도 함께 봅니다. 기본 로케일은finally에서 되돌립니다.수정 지점만 되돌린 상태(RED)
수정 후(GREEN, 모듈 전체)