chore: dedupe TeeSink typed writes and tidy logging/redaction helpers#188
Merged
Merged
Conversation
Trim a few self-contained duplications in the io and instrumentation packages. All changes are behavior-preserving and touch only internal or private members. - TeeSink: replace the hand-rolled if/else min in tapAllowance with the standard minOf clamp, and fold the five typed-write overrides (write/writeUtf8/writeString) onto a single private inline `staged` helper that stages into the scratch buffer, tees, and drains. The helper takes the staging buffer as an explicit lambda argument rather than a Buffer receiver, so an unqualified write can never resolve back to the TeeSink itself and self-recurse. - ClientLogger: drop the pass-through toSlf4j and inline its level mapping into slf4jLevel; point canLog at slf4jLevel directly. Removes one redundant forwarding hop; canLog's signature is unchanged. - UrlRedactor: collapse appendRedactedPair's three-local conditional block to a single eq < 0 early return for the bare-name case, so the value substring and allow-list decode are computed only when a value is actually present. Output is byte-for-byte identical. Closes #178
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.
Trims a handful of small, self-contained duplications in the
ioandinstrumentationpackages ofsdk-core. Every change is behavior-preserving and touches onlyinternalorprivatemembers, so there is no public-API change and noapiDump.Changes
TeeSinktapAllowancenow uses the standardminOfclamp instead of a hand-rolledif/elsemin — identical result, clearer intent. The remaining-budgetcoerceAtLeast(0L)is preserved.write(ByteArray),write(ByteArray, off, len),writeUtf8,writeUtf8(range),writeString) shared the same stage → drain →return thistriple. They now route through a singleprivate inline fun staged(...). The helper takes the staging buffer as an explicit lambda argument (it) rather than aBufferreceiver, so an unqualifiedwrite(...)can never resolve back to theTeeSink's own overrides and self-recurse.writeAll's per-chunk pump loop andwrite(Buffer, Long)are left untouched.ClientLoggertoSlf4jand inlined itsLogLevel → Levelmapping intoslf4jLevel, whose only other caller isLoggingEvent.canLognow callsslf4jLeveldirectly. One redundant forwarding hop removed;canLog's public signature is unchanged.UrlRedactorappendRedactedPaircollapses its three-local conditional block (encodedName/hasValue/encodedValue) into a single early return for the bare-name (eq < 0) case. The value substring and the allow-list decode are now computed only when a value is actually present; the bare-name path emits the name verbatim and returns. Redacted output is byte-for-byte identical.Verification
:sdk-core:compileKotlinand ktlint pass.TeeSink,ClientLogger,UrlRedactor, andLoggableRequestBodypass.Closes #178