fix: LeaveaTrace의 PathMatcher 주입 조건 극성 수정 - #294
Open
z3rotig4r wants to merge 1 commit into
Open
Conversation
TraceHandlerService 에 PathMatcher 가 이미 있을 때만 다시 주입하도록 조건이 반대로 걸려 있었다. 그 결과 관리자 빈에 PathMatcher 를 명시 주입하지 않은 설정에서는 매니저의 pm 이 계속 null 로 남아 AbstractTraceHandleManager.enableMatcher() 가 false 를 반환하고, DefaultTraceHandleManager.trace() 가 즉시 종료되어 leaveaTrace 후처리 핸들러가 한 번도 실행되지 않았다. LeaveaTrace 가 가진 기본 AntPathMatcher 필드도 사용되지 않는 상태였다. 같은 프레임워크의 예외 처리 경로인 ExceptionTransfer.processHandling() 은 hasReqExpMatcher() 가 false 일 때 주입하므로 그 규칙에 맞춘다. 사용자가 명시 주입한 PathMatcher 가 기본 matcher 로 덮어써지던 문제도 함께 해소된다. matcher 미주입 구성과 사용자 지정 matcher 구성을 각각 검증하는 단위 테스트를 추가했다. 기존 CmmnTestConfig 는 setReqExpMatcher() 를 명시 호출해 이 결함이 드러나지 않으므로 신규 테스트에서 matcher 를 주입하지 않은 매니저를 직접 구성했다.
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.
문제
LeaveaTrace.trace()는 등록된TraceHandlerService에 기본PathMatcher(필드pm,AntPathMatcher)를 넘겨줍니다. 그런데 조건이if (traceHandlerService.hasReqExpMatcher())로 되어 있어 matcher가 이미 있을 때 덮어쓰고 없을 때는 넣지 않습니다. 판정이 뒤집혀 있어 결함이 두 갈래로 나타납니다.pm이 계속 null이므로DefaultTraceHandleManager.trace()가 첫 줄if (!enableMatcher()) return false;에서 바로 돌아옵니다. 패턴 매칭에 도달하지 못해 등록한TraceHandler가 한 번도 호출되지 않습니다.setReqExpMatcher()는 조건 없이 대입하는 setter입니다.trace()를 호출할 때마다 사용자가 넣은 matcher를 기본AntPathMatcher로 덮어씁니다.같은 모듈의
ExceptionTransfer.processHandling()은 동일한 자리에서if (!ehm.hasReqExpMatcher())를 씁니다. 예외 처리 쪽 코드가 원래 의도를 그대로 보여줍니다.수정
조건을
if (!traceHandlerService.hasReqExpMatcher())로 반전했습니다(한 줄). matcher가 없는 매니저에만 기본 matcher를 주입하고 이미 설정된 matcher는 건드리지 않습니다. 위 두 결함이 함께 해소됩니다.검증
LeaveaTraceMatcherInjectionTest3건을 추가했습니다.match()가 실제로 호출되고 교체되지 않는지 확인(AntPathMatcher를 상속한 스파이로 기록)LeaveaTrace의 한 줄만 되돌리면 앞의 두 건이 실패합니다. 사용자 matcher가 덮어써지는 쪽은 핸들러 호출 횟수만으로는 드러나지 않아 스파이의match()호출 여부를 함께 검증했습니다. 모듈 전체mvn test29건 green입니다.영향 범위
변경은
org.egovframe.rte.fdl.cmmn안으로 한정되고 공개 API 시그니처는 그대로입니다.다만 한 가지 덧붙입니다. matcher를 명시하지 않은 기존 설정에서는 지금까지 leaveaTrace 후처리 핸들러가 조용히 실행되지 않았습니다. 이 수정 이후에는 설정대로 실행됩니다. 버전을 올릴 때 없던 핸들러 동작·로그가 새로 나타나는 형태로 관찰됩니다.