Add header logging toggle and isolate batching buffers#100
Open
rtsketo wants to merge 3 commits intoihsanbal:masterfrom
Open
Add header logging toggle and isolate batching buffers#100rtsketo wants to merge 3 commits intoihsanbal:masterfrom
rtsketo wants to merge 3 commits intoihsanbal:masterfrom
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.
Problem
The library had two separate issues.
Response logs never printed response headers.
Printer.printJsonResponse(...)only emitted the response URL, theStatus Code:line, and then the existingBody:block forBASIC/BODY. There was no response-side equivalent of the request header output, so downstream apps had to add their own manualresponse.headerslogging when they needed headers such asx-authentication-token.BatchingSinkcould corrupt its internal buffer under concurrent logging.The sink stored buffers in a
ConcurrentHashMap, but the key was only the log tag. When two requests logged at the same time with the same tag, both threads could append into the sameStringBuilder.StringBuilderis not thread-safe, so concurrent mutation could interleave blocks and trigger crashes such asStringIndexOutOfBoundsExceptionfromBatchingSink.log(...).Fix
logHeaders(enabled)builder flag, defaulting totrue, to control both request and response header sectionsBody:behavior unchangedLevelbehavior while adding the missing response header block underStatus Code:BatchingSinkbuffers by tag and current thread so concurrent same-tag request/response blocks no longer share one mutableStringBuilderTesting
.\\gradlew.bat :lib:test :lib:build