Skip to content

WW-5765 Re-store only the token validated in the request in execAndWait - #2023

Merged
lukaszlenart merged 1 commit into
support/struts-6-x-xfrom
WW-5765-execandwait-validated-token-6x
Oct 16, 2026
Merged

lukaszlenart merged 1 commit into
support/struts-6-x-xfrom
WW-5765-execandwait-validated-token-6x

Conversation

@lukaszlenart

Copy link
Copy Markdown
Member

Fixes WW-5765

Problem

ExecuteAndWaitInterceptor puts a transaction token back into the session every time it returns the wait result, so that an action combining token and execAndWait keeps accepting its wait-page refreshes after TokenInterceptor has consumed the token (WW-1741). It took the value from the token request parameter and the name from struts.token.name, and did so whether or not a token had been validated in the current request, including for execAndWait actions with no token check, such as one using executeAndWaitStack. The value and the name were also read under different names.

Approach

  • TokenHelper.validToken() records the token name and value it accepted in the current ActionContext.
  • The new TokenHelper.restoreValidatedToken() puts exactly that pair back into the session, and does nothing when no token was validated in the current request.
  • ExecuteAndWaitInterceptor calls it instead of reading request parameters.

Behaviour change

A token is now re-stored only if it went through TokenHelper.validToken() earlier in the same request. Setups where that never happened, such as a token interceptor ordered after execAndWait or custom token checking that bypasses TokenHelper, no longer get a token re-stored on the wait result. Worth a line in the migration notes.

Tests

  • ExecuteAndWaitInterceptorTest
    • an execAndWait action without a token interceptor returns wait and leaves the session token store unchanged, for the default and a custom token name; this fails on the previous code;
    • token + execAndWait and tokenSession + execAndWait keep accepting the wait-page refresh that carries the validated token, then consume it on completion.
  • TokenHelperTest: the validated token is restored; a rejected or unvalidated token leaves the session unchanged.
  • ./mvnw -pl core test: 2739 tests, 0 failures, 0 errors.

Port of #2022 to the 6.x line; the only difference is the test imports (com.opensymphony.xwork2).

🤖 Generated with Claude Code

…quest in execAndWait

ExecuteAndWaitInterceptor put a transaction token back into the session
on every wait result, reading the value from the "token" request
parameter and the name from "struts.token.name". It did so whether or
not a token had been validated in the current request, including for
execAndWait actions without a token check, and it read the value and
the name under different names.

TokenHelper.validToken() now records the token name and value it
accepted in the current ActionContext, and the new
TokenHelper.restoreValidatedToken() puts exactly that pair back into
the session. ExecuteAndWaitInterceptor calls it instead of reading
request parameters, so with no validated token it leaves the session
token store unchanged. Actions combining token or tokenSession with
execAndWait keep accepting wait-page refreshes as before (WW-1741).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@lukaszlenart
lukaszlenart marked this pull request as ready for review October 15, 2026 17:06
@sonarqubecloud

Copy link
Copy Markdown

@lukaszlenart
lukaszlenart merged commit cf7d657 into support/struts-6-x-x Oct 16, 2026
10 checks passed
@lukaszlenart
lukaszlenart deleted the WW-5765-execandwait-validated-token-6x branch October 16, 2026 05:01
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