Skip to content

KAFKA-18573: Close verification key resolver in BrokerJwtValidator#22759

Open
FrankYang0529 wants to merge 1 commit into
apache:trunkfrom
FrankYang0529:KAFKA-18573-followup
Open

KAFKA-18573: Close verification key resolver in BrokerJwtValidator#22759
FrankYang0529 wants to merge 1 commit into
apache:trunkfrom
FrankYang0529:KAFKA-18573-followup

Conversation

@FrankYang0529

@FrankYang0529 FrankYang0529 commented Jul 5, 2026

Copy link
Copy Markdown
Member

Why

BrokerJwtValidator#configure obtains a
CloseableVerificationKeyResolver from
VerificationKeyResolverFactory.get() but never closes it, so the JWKS
refresh thread of RefreshingHttpsJwksVerificationKeyResolver leaks.

How

  • BrokerJwtValidator
    • Keeps a reference to the resolver obtained from the factory,
      configures it through the ref-counting wrapper, and releases it in
      close().
    • An injected resolver is not closed. Its lifecycle is managed by the
      code that supplied it.
  • VerificationKeyResolverFactory
    • create() no longer configures the resolver; initialization is
      driven by the wrapper's configure().
    • RefCountingVerificationKeyResolver removes its cache entry when
      the last reference is closed, so a subsequent get() with the same
      configuration builds a fresh resolver instead of returning the closed
      one.

Signed-off-by: PoAn Yang <payang@apache.org>
@FrankYang0529 FrankYang0529 force-pushed the KAFKA-18573-followup branch from 7ee4076 to 72f3beb Compare July 6, 2026 00:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant