Skip to content

[fix][test] Preserve class loading in broker interceptor fixtures - #26567

Merged
merlimat merged 1 commit into
apache:masterfrom
lhotari:lh-fix-interceptor-test-loader
Sep 13, 2026
Merged

[fix][test] Preserve class loading in broker interceptor fixtures#26567
merlimat merged 1 commit into
apache:masterfrom
lhotari:lh-fix-interceptor-test-loader

Conversation

@lhotari

@lhotari lhotari commented Sep 12, 2026

Copy link
Copy Markdown
Member

Motivation

Broker interceptor tests install a mocked NarClassLoader as the thread context class loader while running the HTTP filter chain. A bare mock returns null from getResources, violating the class-loader contract. If logging service-provider discovery first runs in that context, ServiceLoader throws a NullPointerException and the setup request fails with HTTP 500. This makes the result depend on class initialization order.

Modifications

Delegate the context class-loader mocks in the ordinary and exception interceptor fixtures to an empty URLClassLoader with the test class loader as its parent. This preserves class and resource lookup while retaining the existing interceptor behavior and cleanup ownership. Listener-only mocks and test assertions remain unchanged.

Verifying this change

  • Make sure that the change passes the CI checks.

  • Reproduced the setup failure by running BrokerInterceptorTest.asyncResponseFilterTest in isolation before the change; the server stack trace reports the null resource enumeration in ServiceLoader. The same isolated test passes with the change.

  • Both affected test classes passed locally: 33 invocations, zero failures or skips. asyncResponseFilterTest and testMessageAckedExceptions each ran 10 times with retries disabled, using temporary invocation counts removed afterward.

  • ./gradlew spotlessCheck checkstyleMain checkstyleTest passed.

Does this pull request potentially affect one of the following parts:

  • Dependencies (add or upgrade a dependency)
  • The public API
  • The schema
  • The default values of configurations
  • The threading model
  • The binary protocol
  • The REST endpoints
  • The admin CLI options
  • The metrics
  • Anything that affects deployment

Delegate the context loader mocks to an empty URLClassLoader with the test loader as parent, so logging service discovery receives valid resource enumerations.

Assisted-by: Codex
@merlimat
merlimat merged commit f3c647f into apache:master Sep 13, 2026
43 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants