Skip to content

KAFKA-19470: Cache Scala logger wrappers - #23044

Open
lh0156 wants to merge 1 commit into
apache:trunkfrom
lh0156:agent/KAFKA-19470-cache-loggers
Open

KAFKA-19470: Cache Scala logger wrappers#23044
lh0156 wants to merge 1 commit into
apache:trunkfrom
lh0156:agent/KAFKA-19470-cache-loggers

Conversation

@lh0156

@lh0156 lh0156 commented Aug 2, 2026

Copy link
Copy Markdown

Closes KAFKA-19470

Summary

  • Cache the immutable Scala logger wrapper by logger name in kafka.utils.Logging.
  • Preserve custom loggerName overrides by using the resolved name as the cache key.
  • Add a regression test proving that multiple instances with the same logger name share the wrapper.

Logging.logger was previously initialized independently for every object instance. The underlying SLF4J logger is name-based, so the wrapper can be reused safely. A ConcurrentHashMap keeps 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=plain

The 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.

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>
@github-actions github-actions Bot added triage PRs from the community core Kafka Broker small Small PRs labels Aug 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Kafka Broker small Small PRs triage PRs from the community

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant