Description
When calling MergeRequestApi.acceptMergeRequest(projectId, mrIid), the HTTP request line and headers are not logged, even though the response is logged normally.
Root cause
In MaskingLoggingFilter.aroundWriteTo(), there's a conditional check that only logs when the media type is application/json or application/x-www-form-urlencoded:
|
if (mediaType.isCompatible(MediaType.APPLICATION_JSON_TYPE) |
|
|| mediaType.isCompatible(MediaType.APPLICATION_FORM_URLENCODED_TYPE)) { |
|
log(stream.getStringBuilder(MessageUtils.getCharset(mediaType))); |
|
} |
For text/plain the request line and headers accumulated in the StringBuilder are discarded.
Expected Log (should show PUT request)
11:57:55,027 INFO [train-processor-1] 1 - Sending client request on thread train-processor-1
1 > PUT http://localhost:8929/api/v4/projects/1/merge_requests/2/merge
1 > Accept: application/json
1 > Content-Type: text/plain
1 > PRIVATE-TOKEN: ********
11:57:55,188 INFO [train-processor-1] 1 - Received server response on thread train-processor-1
1 < 422
1 < Cache-Control: no-cache
1 < Content-Length: 37
1 < Content-Type: application/json
...
Current Behavior (request missing)
Only the response is logged; the request line and headers are lost.
Question
Why does the if condition in aroundWriteTo() restrict logging only to JSON and form-urlencoded? Without this check, the request logs appear correctly. I've already run some tests without that if statement and everything seems okay.
Description
When calling
MergeRequestApi.acceptMergeRequest(projectId, mrIid), the HTTP request line and headers are not logged, even though the response is logged normally.Root cause
In
MaskingLoggingFilter.aroundWriteTo(), there's a conditional check that only logs when the media type isapplication/jsonorapplication/x-www-form-urlencoded:gitlab4j-api/gitlab4j-api/src/main/java/org/gitlab4j/api/utils/MaskingLoggingFilter.java
Lines 344 to 347 in 6478b39
For
text/plainthe request line and headers accumulated in the StringBuilder are discarded.Expected Log (should show PUT request)
Current Behavior (request missing)
Only the response is logged; the request line and headers are lost.
Question
Why does the if condition in
aroundWriteTo()restrict logging only to JSON and form-urlencoded? Without this check, the request logs appear correctly. I've already run some tests without thatifstatement and everything seems okay.