You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Support late servlet content types for snippet injection - #20921
CopilotAI
changed the title
[WIP] Fix servlet output stream injection for content type HTML
Support late servlet content types for snippet injection
Oct 23, 2026
This PR lets servlet streams and writers be acquired before an HTML content type is set, extending snippet injection support across both servlet namespaces.
Changes:
Check injection eligibility at write time and discard partial matches across non-HTML writes.
Preserve once-only injection and track content length before the content type is known.
Add regression coverage for late content types, split writes, reacquisition, and committed responses.
[Testing] This new class calls the wrapper and injection helper directly without requiring an installed agent, so its location does not follow .github/instructions/java-tests.instructions.md:22–25. Move it to the servlet-3.0 javaagent module's src/unitTests/java and register a unitTestsJvmTestSuite; apply the same change to the new servlet-5.0/javaagent-unit-tests/src/test/java/io/opentelemetry/javaagent/instrumentation/servlet/v5_0/snippet/LateContentTypeTest.java:33. Existing standalone tests need not be migrated in this PR.
The reason will be displayed to describe this comment to others. Learn more.
🟢 Approval recommended
The write-time eligibility changes are consistent across both servlet namespaces, with focused regression coverage and no unresolved blocking findings.
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
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.
Allow servlet streams and writers to be acquired before the response becomes HTML, provided the content type is set before writing the head tag.
Fixes #8869.