fix: ShellScriptSupport.isUnix()가 AIX에서 항상 false를 반환하는 문제 수정 - #333
Open
wantaekchoi wants to merge 1 commit into
Open
fix: ShellScriptSupport.isUnix()가 AIX에서 항상 false를 반환하는 문제 수정#333wantaekchoi wants to merge 1 commit into
wantaekchoi wants to merge 1 commit into
Conversation
한 줄 안에서 세 비교가 서로 다르다.
return (OS.indexOf("nix") >= 0 || OS.indexOf("nux") >= 0 || OS.indexOf("aix") > 0);
AIX의 os.name은 "AIX"이므로 소문자화하면 "aix"가 되고 indexOf는 0을 돌려준다.
> 0 이라 이 조건은 성립할 수 없다. 형제 두 비교는 >= 0을 쓴다. 즉 "aix" 토큰은
자기가 매칭할 수 있는 유일한 문자열에 대해 죽어 있다.
같은 메서드가 로케일에도 걸린다. OS는 인자 없는 toLowerCase()로 만들어지는데,
터키어·아제르바이잔어 로케일에서 "AIX"는 점 없는 ı가 섞인 "aıx"가 되어
indexOf("aix")가 -1이 된다. >= 0으로 고쳐도 그 로케일에서는 여전히 못 찾는다.
두 원인이 같은 판정 하나에 겹쳐 있어 함께 고쳤다.
같은 결함 클래스를 Locale.ROOT로 고친 선례가 이 저장소에 있다 —
DefaultMapUserDetailsMapping의 컬럼명 소문자화(eGovFramework#321).
OS 필드는 클래스 로드 시 한 번만 채워지므로, 테스트는 리플렉션으로 값을 바꿔
판정 로직만 확인하고 원래 값으로 되돌린다. 로케일 쪽은 필드가 이미 채워진 뒤라
같은 방식으로 재현할 수 없어 테스트가 덮지 못한다.
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
ShellScriptSupport.isUnix()한 줄 안에서 세 비교가 서로 다릅니다.AIX의
os.name은"AIX"이므로 소문자화하면"aix"가 되고indexOf는 0을 돌려줍니다.> 0이라 이 조건은 성립할 수 없습니다. 즉"aix"토큰은 자기가 매칭할 수 있는 유일한 문자열에 대해 죽어 있습니다.같은 판정이 로케일에도 걸립니다.
OS는 인자 없는toLowerCase()로 만들어지는데, 터키어·아제르바이잔어 로케일에서"AIX"는 점 없는ı가 섞인"aıx"가 되어indexOf("aix")가 -1이 됩니다.>= 0으로 고쳐도 그 로케일에서는 여전히 못 찾습니다. 두 원인이 같은 판정 하나에 겹쳐 있어 함께 고쳤습니다.AS-IS
TO-BE
같은 결함 클래스를
Locale.ROOT로 고친 선례가 이 저장소에 있습니다 —DefaultMapUserDetailsMapping의 컬럼명 소문자화(#321).영향 범위
isWindows()·isMac()·isSolaris()의 판정은 그대로입니다. 바뀌는 것은 AIX에서isUnix()가 이제true를 돌려준다는 점뿐입니다.JUnit 테스트 JUnit tests
ShellScriptSupportOsTest2건을 추가했습니다.OS필드는 클래스 로드 시 한 번만 채워지므로, 리플렉션으로 값을 바꿔 판정 로직만 확인하고finally에서 되돌립니다.수정 지점만 되돌린 상태(RED)
수정 후(GREEN, 모듈 전체)
로케일 쪽은
OS가 이미 채워진 뒤라 같은 방식으로 재현할 수 없어 테스트가 덮지 못합니다.