Fix empty response body on Jetty HttpClient 9.4.24–9.4.43#16406
Merged
trask merged 3 commits intoopen-telemetry:mainfrom Mar 9, 2026
Merged
Conversation
In Jetty 9.4.24, Response.DemandedContentListener was introduced as a standalone interface. HttpReceiver.ContentListeners filters listeners via instanceof DemandedContentListener before delivering content. In versions 9.4.24–9.4.43, AsyncContentListener and ContentListener do not extend DemandedContentListener, so the Proxy created by JettyClientWrapUtil fails the instanceof check and content is never delivered. Fix by reflectively loading DemandedContentListener (when available) and including it in the proxy's interface list. Fixes open-telemetry#16405 Made-with: Cursor
b4974f7 to
6a9b2b0
Compare
laurit
approved these changes
Mar 9, 2026
Contributor
|
Thank you for your contribution @imrahul23! 🎉 We would like to hear from you about your experience contributing to OpenTelemetry by taking a few minutes to fill out this survey. |
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.
Fixes #16405
Summary
Response.DemandedContentListener(introduced in Jetty 9.4.24) and include it in the proxy's interface list inJettyClientWrapUtilContentResponseandInputStreamResponseListenercontent deliveryProblem
In Jetty 9.4.24–~9.4.43,
Response.DemandedContentListeneris a standalone interface —AsyncContentListenerandContentListenerdo not extend it. Jetty'sHttpReceiver.ContentListenersfilters listeners viainstanceof DemandedContentListenerbefore delivering content.JettyClientWrapUtilwraps response listeners in ajava.lang.reflect.Proxywhose interface list does not includeDemandedContentListener. The proxy fails theinstanceofcheck, gets filtered out, and response content is never delivered — resulting in empty response bodies.In later Jetty versions (~9.4.44+),
AsyncContentListener extends DemandedContentListener, so the proxy inherits it automatically and the bug does not manifest.Fix
DemandedContentListenerdoes not exist in Jetty 9.2 (the compile target), so it is loaded reflectively viaClass.forName(). If present, it is added to thelistenerInterfacesarray. If absent (pre-9.4.24), it is a no-op.Test plan
JettyHttpClient9HttpCallTest.contentResponseBodyIsDelivered— synchronousContentResponsepathJettyHttpClient9HttpCallTest.inputStreamListenerBodyIsDelivered— asyncInputStreamResponseListenerpathJettyHttpClient9LibraryTestsuite passesDemandedContentListener— reflective load returns null, no-op)Made with Cursor