Repository navigation
[logging] 본문 캐싱 후 form 요청 파라미터가 사라지는 문제 수정 - #6
Merged
Merged
Conversation
There was a problem hiding this comment.
This PR fixes a bug where application/x-www-form-urlencoded POST request parameters were lost after LoggingFilter cached the request body.
Key changes:
CachedRequestBodyWrappernow implementsgetParameter,getParameterMap,getParameterNames, andgetParameterValues.- For form POST requests, it merges query-string parameters with parameters parsed from the cached request body.
- Query parameters remain first for duplicate names, matching servlet-container behavior.
- Form body parsing uses the request charset, falling back to UTF-8, and skips malformed encoded pairs rather than failing the request.
- PUT/PATCH/DELETE behavior is left unchanged because Spring’s
FormContentFilterhandles those bodies. - Adds integration tests using a real Tomcat server to verify that form body parameters reach the controller after body caching.
- Bumps version from
2.0to2.0.1and updates README install examples.
6 inline comment(s)
snowykte0426
approved these changes
Nov 12, 2026
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.
개요
LoggingFilter를 거친application/x-www-form-urlencodedPOST 요청에서 본문 파라미터가 사라지는 문제를 수정하고, 버전을 2.0.1로 올립니다.원인
CachedRequestBodyWrapper는 생성될 때request.inputStream을 끝까지 읽어 본문을 캐시합니다. 그런데getParameter*()는 다시 구현하지 않아 원본 요청으로 위임됩니다. Tomcat은getInputStream()이 이미 호출된 요청의 form 본문을 파라미터로 해석하지 않으므로, 컨트롤러의@RequestParam에는 쿼리스트링 값만 들어옵니다.JSON 요청은 캐시한 본문을 Jackson이
getInputStream()으로 다시 읽기 때문에 영향이 없습니다. 1.5와 2.0 모두 같은 코드라서 두 버전 모두 해당합니다.변경 사항
CachedRequestBodyWrapper가getParameter,getParameterMap,getParameterNames,getParameterValues를 직접 구현합니다.FormContentFilter가 캐시한 본문을 다시 읽어 처리하므로 기존 동작을 그대로 둡니다.테스트
LoggingFilterFormRequestTest를 추가했습니다. MockMvc는 form 본문을 미리 파라미터로 채워 주기 때문에 이 버그를 재현하지 못합니다. 그래서RANDOM_PORT로 실제 Tomcat을 띄워 검증합니다.+,%2B디코딩 포함)와 쿼리 파라미터가 모두 컨트롤러에 전달되는지FormContentFilter가 정확히 한 번 채우는지CachedRequestBodyWrapper를 거쳤는지(sdk.logging.enabled=true를 명시해 전제가 조용히 깨지지 않게 함)./gradlew build(ktlint 포함, 전체 42개 테스트) 통과리뷰 반영
maxPostSize/maxParameterCount가 적용되지 않는다는 점과not-logging-urls권장 사항도 함께 적었습니다.배포
머지 후 master에서
2.0.1태그로 릴리즈를 게시하면 CD가 Maven Central에 배포합니다.