Skip to content

Migrate TestingBotTestEmbed to Jakarta (StaplerRequest2); fix stale-render bug#27

Merged
jochen-testingbot merged 4 commits into
masterfrom
l3-jakarta
Jul 16, 2026
Merged

Migrate TestingBotTestEmbed to Jakarta (StaplerRequest2); fix stale-render bug#27
jochen-testingbot merged 4 commits into
masterfrom
l3-jakarta

Conversation

@jochen-testingbot

@jochen-testingbot jochen-testingbot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Completes the Jakarta migration — TestingBotTestEmbed.doIndex was the last javax.servlet/StaplerRequest usage. Migrated to StaplerRequest2/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 verify green (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 (BuildWrapperSimpleBuildWrapper, RunListener<AbstractBuild>) are deferred — they're L-effort and structurally entangled with why a separate TestingBotTunnelStep exists.

Summary by CodeRabbit

  • Bug Fixes
    • Ensured the test result page consistently uses the first matching session for each request.
    • Prevented previously selected build information from carrying over between requests.
    • Updated the embedded page rendering to use the per-request selected build details (test name, links, and iframe source).
  • Compatibility
    • Updated request handling to the newer web framework interfaces and servlet exception types.

…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.
@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: df97aaa1-98ec-4fc2-b42f-b90b6adb9007

📥 Commits

Reviewing files that changed from the base of the PR and between 1fd83d6 and 0a78b17.

📒 Files selected for processing (1)
  • src/main/java/testingbot/TestingBotBuildObject.java

📝 Walkthrough

Walkthrough

TestingBotTestEmbed now uses Stapler 2 and Jakarta Servlet APIs. Its request handler selects the first matching build object per request, stores it in request attributes, and forwards either the result or default Jelly view. The Jelly view reads this request-scoped object.

Changes

TestingBot test embedding

Layer / File(s) Summary
Update request handler and view selection
src/main/java/testingbot/TestingBotTestEmbed.java
Replaces Stapler 1 and javax.servlet types, removes logging and instance-scoped selection, selects the first matching session object, stores it on the request, and forwards the appropriate view.
Pass selected data to the rendered view
src/main/java/testingbot/TestingBotBuildObject.java, src/main/resources/testingbot/TestingBotTestEmbed/show.jelly
Derives environmentName from constructor input without retaining the test object, and updates the Jelly view to read test details and embed URLs from the request-scoped object.

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
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately captures the Jakarta/StaplerRequest2 migration and the stale-render fix in TestingBotTestEmbed.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
⚔️ Resolve merge conflicts
  • Resolve merge conflict in branch l3-jakarta

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai 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.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 8477738 and 51c7659.

📒 Files selected for processing (1)
  • src/main/java/testingbot/TestingBotTestEmbed.java

Comment thread src/main/java/testingbot/TestingBotTestEmbed.java Outdated
…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
@jochen-testingbot
jochen-testingbot merged commit 2a0f932 into master Jul 16, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant