KAFKA-19470: Cache Scala logger wrappers - #23044
Open
lh0156 wants to merge 1 commit into
Open
Conversation
Reuse the immutable Scala logger wrapper for instances that resolve to the same logger name. This avoids recreating the wrapper for every Logging instance while preserving custom loggerName overrides. Tests: ./gradlew :core:test --tests kafka.utils.LoggingTest --no-build-cache --rerun-tasks --console=plain Generated-by: OpenAI Codex (GPT-5) Signed-off-by: 엄윤섭 <62834176+lh0156@users.noreply.github.com>
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.
Closes KAFKA-19470
Summary
kafka.utils.Logging.loggerNameoverrides by using the resolved name as the cache key.Logging.loggerwas previously initialized independently for every object instance. The underlying SLF4J logger is name-based, so the wrapper can be reused safely. AConcurrentHashMapkeeps the lookup thread-safe while allowing concurrent construction to converge on one cached wrapper.Tests
./gradlew :core:test --tests kafka.utils.LoggingTest --no-build-cache --rerun-tasks --console=plain./gradlew :core:spotlessCheck --no-build-cache --console=plainThe regression test was first verified to fail against the base branch, then passed after the cache implementation was added. Core Checkstyle and SpotBugs also passed as part of the test build.