fix: EgovWebServiceMessageHeader.setResultCode 가 null 을 막지 못해 응답 헤더 복사가 죽는 문제 수정 - #361
Open
wantaekchoi wants to merge 1 commit into
Open
fix: EgovWebServiceMessageHeader.setResultCode 가 null 을 막지 못해 응답 헤더 복사가 죽는 문제 수정#361wantaekchoi wants to merge 1 commit into
wantaekchoi wants to merge 1 commit into
Conversation
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
EgovWebServiceMessageHeader는 읽기 쪽과 쓰기 쪽이 어긋나 있습니다.getResultCode()는 결과 코드가 빈 헤더에서 null 을 돌려주는데,setResultCode(ResultCode)는 인자를 검사 없이 역참조합니다.ResultCode.getCode는codes.get(value)뿐이라, 값이 없으면 예외 없이 null 이 나옵니다(EgovIntegrationMessageHeader.java:417-419).둘을 이어 붙이는 곳이 같은 클래스의 복사 생성자(120줄)입니다. 132줄
setResultCode(header.getResultCode());가 자기 getter 가 만든 null 을 자기 setter 에 그대로 넣습니다.서버 진입점
ServiceBridgeImpl.doService()는 정상 분기(155-161줄)에서 요청 헤더를 그 생성자에 그대로 넘깁니다(ServiceBridgeImpl.java:161,new EgovWebServiceMessageHeader(requestHeader)).트리거가 넓지는 않습니다.
EgovWebService가 기본 헤더를ResultCode.OK로 채워(EgovWebService.java:114)createRequestMessage()를 거친 eGov 클라이언트 요청은 이 null 을 만들지 않습니다. 남는 것은 외부 SOAP 클라이언트가 보낸 헤더와 직접 조립한 헤더입니다. 결과 코드는 응답이 산출하는 값이라 요청자가 채울 이유가 없고, 필드가protected String resultCode(101줄)라 JAXB 는 없는 엘리먼트를 null 로 남깁니다.빈도가 아니라 한 클래스 안에서 읽기 쪽이 허용하는 값을 쓰기 쪽이 못 받는다는 점이 문제라고 봤습니다. 형제 구현은 같은 자리에서 null 을 그대로 받습니다.
SimpleMessageHeader는 필드가protected ResultCode resultCode(94줄)라 대입만 하면 되고, 이쪽은 JAXB 직렬화 때문에 String 필드를 써 enum → String 변환이 필요합니다. 인터페이스EgovIntegrationMessageHeader의 선언(186줄, 193줄)에도 non-null 제약은 없습니다.AS-IS / TO-BE
public void setResultCode(ResultCode resultCode) { - this.resultCode = resultCode.getValue(); + this.resultCode = resultCode != null ? resultCode.getValue() : null; }null 을 저장하면
getResultCode()가ResultCode.getCode(null)로 다시 null 을 돌려주어 읽기 쪽과 왕복이 맞습니다. 기본값ResultCode.OK를 채우면 결과 코드를 모르는 헤더가 정상 종료로 보이고 형제SimpleMessageHeader와도 갈라집니다.호출부마다 막지 않고 setter 한 곳을 고쳤습니다. 복사 생성자와 전체 인자 생성자가 모두 이 메서드를 지납니다.
영향 범위
인자가 null 일 때의 동작만 바뀝니다.
이 복사 생성자를 쓰는 자리는
src/main안에 16곳입니다(EgovWebService4곳,EgovWebServiceClientImpl6곳,ServiceBridgeImpl6곳). 그중 요청 헤더로 응답 헤더를 만드는 12곳(EgovWebServiceClientImpl6곳,ServiceBridgeImpl6곳)이 같이 닫힙니다. 나머지 4곳은EgovWebService가 자기 기본 헤더를 넘기는 자리입니다.형제
TypedMessageHeader도 267줄에서 같은 무가드 역참조를 하고 262-263줄 getter 는 null 을 허용합니다. 다만 복사 생성자가 없어 이 경로로는 도달하지 않고, 모듈도itl.integration이라 범위에서 뺐습니다.JUnit 테스트 JUnit tests
EgovWebServiceMessageHeaderNullResultCodeTest를 더했습니다. 헤더를 손으로 조립하지 않고,resultCode엘리먼트가 없는 헤더 XML 을 JAXB 로 언마샬해ServiceBridgeImpl이 받는 것과 같은 객체를 복사 생성자에 넣습니다.수정을 뺀 상태입니다(패키지 접두어 생략).
target/surefire-reports의 스택입니다.수정 후 같은 명령입니다.
기존 22건은 수정 전후 모두 통과하고, 새 테스트 3건이 더해져 25건입니다. 그중
EgovWebServiceTest7건에EchoEgovWebServiceClient가 같은 복사 생성자를 쓰는 경로가 있습니다(EgovWebServiceTest.java:250-251).컨테이너를 띄운 SOAP 왕복 확인은 하지 않았습니다.
테스트 브라우저 Test Browser
테스트 스크린샷 또는 캡처 영상 Test screenshots or captured video
화면이 없는 실행환경 모듈이라 첨부하지 않았습니다.