Conversation
HttpServletExtractAdapter.Response called HttpServletResponse.getHeaderNames() on every response. A response class compiled against Servlet 2.5 (for example an old wrapper) does not implement it, so the call threw AbstractMethodError and aborted the AppSec/IAST response-header callbacks on every response of that class. Read directly until a class fails, then remember unsupported classes in a ClassValue (probing for an abstract interface method) so they are skipped without throwing, and read headers from a wrapped delegate when there is one. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Contributor
Contributor
🟢 Java Benchmark SLOs — All performance SLOs passed
PR vs. master results
Commit: Load and DaCapo benchmarks can be triggered manually in the GitLab pipeline. Results will appear in the Benchmarking Platform UI after completion. |
This branch has not been deployed
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.
What Does This Do
Makes the servlet 3.0 response-header reader tolerate response classes that do not implement the Servlet 3.0 header accessors.
HttpServletExtractAdapter.ResponsecalledHttpServletResponse.getHeaderNames()/getHeader(...)on every response. A response class compiled against Servlet 2.5 (for example an old wrapper bundled in a webapp) does not implement them, so the call throwsAbstractMethodError. It escaped throughHttpServerDecorator.callIGCallbackResponseAndHeaders, was caught and reported as "Failed to decorate span on response", and stopped the response-header callbacks on every response of that class.Now
Response.forEachKey:static booleanread (anyUnsupported).AbstractMethodErrorfrom the two accessor calls only, sets the flag, and marks that response class unsupported in aClassValue.getMethodplusModifier.isAbstract) decides whether a class supports header access, so other bad classes never throw.ServletResponseWrapper(bounded depth) and reads headers from the nearest delegate that supports them; if there is none, it visits no headers.The new nested
HeaderAccessorshelper is added to both helper-class lists that injectHttpServletExtractAdapter(Servlet3InstrumentationandAsyncContextInstrumentation).Adds
HttpServletExtractAdapterTest(JUnit 5, 6 cases), using an ASM-generated response class that implementsHttpServletResponsebut none of its methods, so the realAbstractMethodErroris exercised.Motivation
Instrumentation telemetry shows this at
HttpServletExtractAdapter$Response.getHeaderNames:48: about 10.5k events a day, steady at 400-500 an hour, on tracers 1.58 to 1.66, mostly Java 8 services (a fewpauth/pentitlements/poauth-style services,azkaban-*,wc-commerce-*). Reports aggregate repeats, so the real throw count is higher.Muzzle cannot catch this: it verifies that
HttpServletResponse.getHeaderNames()exists in the API, and it does. The failure is that a particular runtime implementation does not honor it.Additional Notes
For the AppSec/IAST reviewers, please look at this:
callIGCallbackResponseAndHeaderstheresponseStarted(status)callback fires before the header visit, so it was not affected. What was skipped is the response-header callbacks andigKeyClassifier.done()(responseHeaderDone).done()still runs with no headers (like an empty header set). The servlet 2.x decorator instead returns anullresponseGetter()("There is no way to access the headers"), which skips the header callbacks anddone()entirely. I went with "empty headers" soresponseHeaderDonestill fires. Happy to switch to the 2.x behavior if AppSec prefers it.classifier.acceptcallback: anAbstractMethodErrorthrown by callback code says nothing about the response class and must not mark it unsupported (there is a test for this). IfgetHeaderfails part-way through, it stops instead of retrying, to avoid re-emitting keys.Notes:
ServletResponseWrappersubclasses (so the unwrap fallback helps) is a guess: the telemetry only shows our adapter frames.Contributor Checklist
type:and (comp:orinst:) labels in addition to any other useful labelsclose,fix, or any linking keywords when referencing an issueUse
solvesinstead, and assign the PR milestone to the issueJira ticket: N/A
🤖 Generated with Claude Code