Migrate TestingBotTestEmbed to Jakarta (StaplerRequest2); fix stale-render bug#27
Conversation
…render bug TestingBotTestEmbed.doIndex was the last javax.servlet / StaplerRequest usage. Migrate to StaplerRequest2 / StaplerResponse2 / jakarta.servlet.ServletException (the stack the plugin already builds against under parent 6.x / jenkins 2.541.3). Also fix the shared-mutable-field render bug (review finding): doIndex wrote the matched session into the shared 'tbo' field and never reset it, so a later request with an unmatched sessionId re-rendered the previously selected session's media. Resolve into a local and reset the selection each request. Drop the unused Stapler/Logger imports. mvn clean verify green (21 tests, SpotBugs 0); no javax.servlet references remain in src.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthrough
ChangesTestingBot test embedding
Estimated code review effort: 2 (Simple) | ~10 minutes Sequence Diagram(s)sequenceDiagram
participant Client
participant TestingBotTestEmbed
participant StaplerRequest2
participant show_jelly
Client->>TestingBotTestEmbed: request sessionId
TestingBotTestEmbed->>TestingBotTestEmbed: select first matching build object
TestingBotTestEmbed->>StaplerRequest2: set request attribute tbo
TestingBotTestEmbed->>show_jelly: forward selected view
show_jelly->>StaplerRequest2: read attribute tbo
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
⚔️ Resolve merge conflicts
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/main/java/testingbot/TestingBotTestEmbed.java`:
- Around line 55-66: Remove the shared-state assignment to this.tbo in the
request handling flow, and pass the locally selected TestingBotBuildObject
directly through a request-scoped view model or equivalent mechanism used by
show.jelly. Ensure concurrent requests cannot overwrite each other’s selected
session media or authHash, while preserving index.jelly for unmatched sessions.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: a06faee0-bf3f-4ab8-97ca-c731f2b190ef
📒 Files selected for processing (1)
src/main/java/testingbot/TestingBotTestEmbed.java
…otTest
Review finding: TestingBotTestEmbed.doIndex stored the selected session in a shared per-action field
that concurrent requests could overwrite (wrong session's media/authHash). Pass the selection through
a request attribute (request-scoped) that show.jelly reads; drop the shared 'tbo' field/getter.
While verifying the render end-to-end, found that persisting the action failed the JEP-200 class
filter ('Refusing to marshal com.testingbot.models.TestingbotTest') — so the embedded-reports feature
could not be saved at all. TestingBotBuildObject's 'test' field is only used in the constructor to
derive environmentName and is never read afterwards, so make it transient. Verified on a running
Jenkins: the action now saves (build.xml contains it) and both the show and index views render.
…_NOT_RESTORED) Making the field transient tripped SpotBugs SE_TRANSIENT_FIELD_NOT_RESTORED. Since the TestingbotTest is only consumed by the constructor to derive environmentName and is never read afterwards, don't store it at all (drop the field and the unused getTest/setTest). Resolves the JEP-200 marshal failure without a suppression. mvn clean verify green (SpotBugs 0, 21 tests).
# Conflicts: # src/main/java/testingbot/TestingBotBuildObject.java
Completes the Jakarta migration —
TestingBotTestEmbed.doIndexwas the lastjavax.servlet/StaplerRequestusage. Migrated toStaplerRequest2/StaplerResponse2/jakarta.servlet.ServletException.Also fixes review finding #8 (shared-mutable-field): the matched session was stored in a shared field and never reset, so a later unmatched request re-rendered the previous session's media. Now resolved into a local + reset per request.
mvn clean verifygreen (21 tests, SpotBugs 0); no javax.servlet references remain in src. The embed view render should be confirmed manually against a build with real TestingBot session data.Note: the larger base-class modernizations (
BuildWrapper→SimpleBuildWrapper,RunListener<AbstractBuild>) are deferred — they're L-effort and structurally entangled with why a separateTestingBotTunnelStepexists.Summary by CodeRabbit