Skip to content

test(servlet): Test Servlet 3.1 and 4.0 runtimes - #6625

Open
adinauer wants to merge 3 commits into
chore/servlet-api-compatibility-stackfrom
test/servlet-api-compatibility-tomcat85
Open

adinauer wants to merge 3 commits into
chore/servlet-api-compatibility-stackfrom
test/servlet-api-compatibility-tomcat85

Conversation

@adinauer

@adinauer adinauer commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

PR Stack (Servlet API)


📜 Description

Add a real-container integration test for sentry-servlet and run it on both Tomcat 8.5 / Servlet 3.1 and Tomcat 9 / Servlet 4.0.

The shared test loads SentryServletContainerInitializer through ServiceLoader, sends an HTTP request through embedded Tomcat, and verifies that the captured Sentry event contains the request method, URL, and query string.

💡 Motivation and Context

Production code remains compiled against the minimum supported Servlet 3.1 API, preserving the compiler-enforced compatibility floor. Running the same test against Servlet 3.1 and Servlet 4.0 verifies both the minimum runtime and the latest javax.servlet runtime.

💚 How did you test it?

  • make format api
  • ./gradlew :sentry-servlet:integrationTest :sentry-servlet:integrationTestTomcat9 --rerun-tasks --no-build-cache
  • Verified compileClasspath resolves javax.servlet-api:3.1.0
  • Verified the isolated JVM test-suite runtime classpaths resolve Tomcat 8.5.100 and Tomcat 9.0.108 respectively

📝 Checklist

  • I added GH Issue ID & Linear ID
  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.
  • Public API changes reviewed by another Mobile SDK team member or implemented according to the develop docs spec.

🔮 Next steps

None.

#skip-changelog

⚠️ Merge this PR using a merge commit (not squash). Only the collection branch is squash-merged into main.

@socket-security

socket-security Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Warning

Socket is a tool Sentry Security team deployed to defend against supply chain attack. Please provide any feedback you have in #discuss-security slack channel ❤️

Priority Alert  (click "▶" to expand/collapse) Action
Critical priority
Critical CVE: Apache Tomcat - Security constraints not correctly applied in maven org.apache.tomcat.embed:tomcat-embed-core

CVE: GHSA-5m62-pw8w-7w9f Apache Tomcat - Security constraints not correctly applied (CRITICAL)

Affected versions: < 9.0.118; >= 10.1.0-M1 < 10.1.55; >= 11.0.0-M1 < 11.0.22

Patched version: 9.0.118

From: gradle/libs.versions.toml → maven/org.apache.tomcat.embed/tomcat-embed-core@8.5.100

ℹ Read more on: This package | This alert | What is a critical CVE?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Remove or replace dependencies that include known critical CVEs. Consumers can use dependency overrides or npm audit fix --force to remove vulnerable dependencies.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore maven/org.apache.tomcat.embed/tomcat-embed-core@8.5.100. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Warn
Critical priority
Critical CVE: Apache Tomcat - Digest authenticator will authenticate any unknown user in maven org.apache.tomcat.embed:tomcat-embed-core

CVE: GHSA-h6fc-48rj-7qqh Apache Tomcat - Digest authenticator will authenticate any unknown user (CRITICAL)

Affected versions: < 9.0.118; >= 10.1.0-M1 < 10.1.55; >= 11.0.0-M1 < 11.0.22

Patched version: 9.0.118

From: gradle/libs.versions.toml → maven/org.apache.tomcat.embed/tomcat-embed-core@8.5.100

ℹ Read more on: This package | This alert | What is a critical CVE?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Remove or replace dependencies that include known critical CVEs. Consumers can use dependency overrides or npm audit fix --force to remove vulnerable dependencies.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore maven/org.apache.tomcat.embed/tomcat-embed-core@8.5.100. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Warn
Critical priority
Critical CVE: Apache Tomcat - HTTP/2 request headers not validated in maven org.apache.tomcat.embed:tomcat-embed-core

CVE: GHSA-r29c-68gh-xp6x Apache Tomcat - HTTP/2 request headers not validated (CRITICAL)

Affected versions: >= 8.5.0 < 9.0.118; >= 10.1.0-M1 < 10.1.55; >= 11.0.0-M1 < 11.0.22

Patched version: 9.0.118

From: gradle/libs.versions.toml → maven/org.apache.tomcat.embed/tomcat-embed-core@8.5.100

ℹ Read more on: This package | This alert | What is a critical CVE?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Remove or replace dependencies that include known critical CVEs. Consumers can use dependency overrides or npm audit fix --force to remove vulnerable dependencies.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore maven/org.apache.tomcat.embed/tomcat-embed-core@8.5.100. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Warn
Medium priority
Critical CVE: Apache Tomcat: Potential RCE and/or information disclosure and/or information corruption with partial PUT in maven org.apache.tomcat.embed:tomcat-embed-core

CVE: GHSA-83qj-6fr2-vhqg Apache Tomcat: Potential RCE and/or information disclosure and/or information corruption with partial PUT (CRITICAL)

Affected versions: >= 8.5.0 <= 8.5.100; >= 9.0.0.M1 < 9.0.99; >= 10.1.0-M1 < 10.1.35; >= 11.0.0-M1 < 11.0.3

Patched version: No patched versions

From: gradle/libs.versions.toml → maven/org.apache.tomcat.embed/tomcat-embed-core@8.5.100

ℹ Read more on: This package | This alert | What is a critical CVE?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Remove or replace dependencies that include known critical CVEs. Consumers can use dependency overrides or npm audit fix --force to remove vulnerable dependencies.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore maven/org.apache.tomcat.embed/tomcat-embed-core@8.5.100. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Warn

View full report

@sentry

sentry Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
SDK Size io.sentry.tests.size 8.64.0 (1) release

⚙️ sentry-android Build Distribution Settings

@adinauer adinauer changed the title test(servlet): [Servlet API 2] Test Servlet 3.1 on Tomcat 8.5 test(servlet): [Servlet API 2] Test Servlet 3.1 and 4.0 runtimes Nov 16, 2026
@adinauer
adinauer marked this pull request as ready for review November 16, 2026 15:11
@adinauer
adinauer requested a review from a team as a code owner November 16, 2026 15:11
@adinauer
adinauer requested review from romtsn and runningcode and removed request for a team November 16, 2026 15:11
@github-actions github-actions Bot added the risk: low PR risk score: low label Nov 16, 2026
Base automatically changed from dependabot/gradle/javax.servlet-javax.servlet-api-4.0.1 to chore/servlet-api-compatibility-stack November 17, 2026 07:05
Run sentry-servlet against the minimum supported servlet container while
keeping Servlet 3.1 as the production compile target. Exercise the
service-loaded initializer through a real HTTP request and verify that
request context reaches Sentry.
Reuse the real-container servlet integration test with a Tomcat 9 and Servlet 4 runtime classpath. Keep the Tomcat 8.5 run as the minimum-runtime check and attach both runs to the verification lifecycle.
@adinauer
adinauer force-pushed the test/servlet-api-compatibility-tomcat85 branch from db8bb6c to 6793b24 Compare November 17, 2026 08:48
@adinauer adinauer changed the title test(servlet): [Servlet API 2] Test Servlet 3.1 and 4.0 runtimes test(servlet): Test Servlet 3.1 and 4.0 runtimes Nov 17, 2026

@runningcode runningcode left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's a couple of gradle quirks in this that would be fixed by using the jvm test suite like we do for the spring boot matrix.

Comment thread sentry-servlet/build.gradle.kts Resolved
Replace the hand-built Tomcat 9 test task with isolated JVM test suites.
Run the shared servlet integration test with independent Tomcat 8.5 and
Tomcat 9 dependency graphs and attach both suites to check.

Co-Authored-By: Claude <noreply@anthropic.com>

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want fixes drafted automatically? Bugbot Autofix can create code changes for findings. A team admin can enable Autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit bc1635c. Configure here.

sources {
java.setSrcDirs(sourceSets["integrationTest"].allJava.srcDirs)
resources.setSrcDirs(sourceSets["integrationTest"].resources.srcDirs)
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tomcat 9 suite skips Kotlin tests

Medium Severity

The integrationTestTomcat9 suite copies integrationTest's allJava.srcDirs, which is src/integrationTest/java, not the Kotlin tests in src/integrationTest/kotlin. Kotlin still compiles src/integrationTestTomcat9/kotlin, so that suite produces no classes and Gradle skips the task as NO-SOURCE. Tomcat 9 / Servlet 4.0 never actually runs.

Fix in Cursor Fix in Web

Triggered by project rule: PR Review Guidelines for Cursor Bugbot

Reviewed by Cursor Bugbot for commit bc1635c. Configure here.

}
}

tasks.check {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't think we run integration tests as part of the check task for other modules. we usually run them separately

Comment thread gradle/libs.versions.toml

# tomcat libraries
tomcat85-embed-core = { module = "org.apache.tomcat.embed:tomcat-embed-core", version = "8.5.100" }
tomcat9-embed-core = { module = "org.apache.tomcat.embed:tomcat-embed-core", version = "9.0.108" }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should probably extract 9.0.108 to a variable so that all the 9.x versions are updated together.

testImplementation(projects.sentryTestSupport)
testImplementation(kotlin(Config.kotlinStdLib))
testImplementation(libs.awaitility.kotlin)
testImplementation(libs.google.truth)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this used?

@runningcode runningcode left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for fixing this! i left some more comments but approving as well!

implementation(libs.kotlin.test.junit)
implementation(libs.tomcat85.embed.core)
}
targets.all {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

another option that would mean we don't have to compile the test twice is to adjust this to have a single test suite but with two targets. the two targets are tomcat 8.5 and tomcat 9.

here's what my agent thinks would work:

register<JvmTestSuite>("integrationTest") {
      useJUnit()
      dependencies {
        implementation(project())
        implementation(projects.sentryTestSupport)
        implementation(libs.google.truth)
        implementation(libs.kotlin.test.junit)
        implementation(libs.tomcat85.embed.core)
      }
      targets.named("integrationTest") {
        testTask.configure { /* Tomcat 8.5 system properties */ }
      }
      targets.register("integrationTestTomcat9") {
        testTask.configure {
          classpath = sourceSets["integrationTest"].output + tomcat9RuntimeClasspath
          /* Tomcat 9 system properties */
        }
      }
    }

Its mostly an opinion though. i'll approve this anyways.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: low PR risk score: low

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants