[fix][test] Preserve class loading in broker interceptor fixtures - #26567
Merged
Conversation
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
lhotari
requested review from
Technoboy-,
dao-jun,
david-streamlio,
merlimat and
nodece
September 12, 2026 21:16
11 tasks
merlimat
approved these changes
Sep 13, 2026
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.
Motivation
Broker interceptor tests install a mocked
NarClassLoaderas the thread context class loader while running the HTTP filter chain. A bare mock returnsnullfromgetResources, violating the class-loader contract. If logging service-provider discovery first runs in that context,ServiceLoaderthrows aNullPointerExceptionand 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
URLClassLoaderwith 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.asyncResponseFilterTestin isolation before the change; the server stack trace reports the null resource enumeration inServiceLoader. The same isolated test passes with the change.Both affected test classes passed locally: 33 invocations, zero failures or skips.
asyncResponseFilterTestandtestMessageAckedExceptionseach ran 10 times with retries disabled, using temporary invocation counts removed afterward../gradlew spotlessCheck checkstyleMain checkstyleTestpassed.Does this pull request potentially affect one of the following parts: