Repository navigation
WW-5849 Add a forward result to replace action chaining - #2129
Merged
Merged
Conversation
lukaszlenart
force-pushed
the
feat/WW-5849-forward-result
branch
from
December 2, 2026 13:14
9a9d578 to
df56dc4
Compare
lukaszlenart
marked this pull request as ready for review
December 2, 2026 13:20
…ning The design: a forward result with a target-side opt-in, a fresh value stack, request parameters re-bound, an explicit two-sided hand-off, a depth limit with a startup cycle check, and Convention's implicit forward to opted-in targets; chain is deprecated in 7.7.0 and removed in 8.0.0. The plan breaks rollout step 1 (7.6.0) into tasks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…limit The forward result runs an opted-in target action in the same request with its own value stack and ActionContext. The target keeps the request, session, application, locale, action mapping and page context, but nothing from the source action. Nested forwards are capped by struts.forward.maxDepth (default 5). A tokenSession replay renders the target's result against the target's stack, through ActionInvocation#getResultInvocation(), and restores the previously bound context afterwards. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The forward result's pass param names the source action's properties to hand off; they are read through bean getters, never OGNL. The new forwardParams interceptor sets each value only on a top-level setter of the target annotated @ForwardParameter, converting it like a request parameter; anything else is dropped with a warning. The hand-off is consumed once, so it cannot reach an action the target chains to. forwardParams runs directly after params in basicStack, defaultStack, paramsPrepareParamsStack (after the second params) and the REST and Bean Validation stacks; a hand-off to a stack without it throws. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ForwardConfigValidator runs when the configuration is built. A forward whose target, namespace or method is not a literal (an expression or a pattern placeholder) or whose pass names are invalid always fails startup. Missing targets, targets that have not opted in, a hand-off to a stack without forwardParams, and cycles in the forward graph are logged at WARN, or fail startup in devMode. The run time follows the same rules. ActionConfigMatcher copies forward result params verbatim, so no URL or pattern variable reaches them; an omitted namespace means the source action's package namespace; a target that only resolves through default-action-ref is refused; an invalid result param fails instead of being ignored; and ActionForwardResult is final. Target classes behind Spring proxies are unwrapped through the new ProxyService#ultimateTargetClassOf(Class). A tokenSession replay no longer re-runs a forward target that rendered nothing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Convention's implicit foo -> foo-bar transfer becomes a forward when foo-bar has opted in, through the forward-target flag or @ForwardTarget on its class (proxies unwrapped). Otherwise it keeps chaining as before, so existing Convention applications work unchanged until chain is removed in 8.0.0. @Result(type = "forward") is supported. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
lukaszlenart
force-pushed
the
feat/WW-5849-forward-result
branch
from
December 2, 2026 14:25
7b31a47 to
d846ac1
Compare
|
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.



Fixes WW-5849
Adds a
forwardresult: a server-side transfer from one action to another within the same request, chosen by the source action's result code. It is meant to replacechain, with both boundaries made explicit:chainis unchanged in this PR. Its deprecation (7.7.0) and removal (8.0.0) are separate tickets. The design is indocs/superpowers/specs/2026-11-08-WW-5849-action-forward-design.mdand the implementation plan indocs/superpowers/plans/2026-12-02-WW-5849-forward-result.md.What it does
actionName,namespaceandmethodare literals. A${...},%{...}or wildcard/pattern placeholder{x}fails configuration at startup in every mode.ActionConfigMatchercopies forward-result params verbatim, so no URL or pattern variable reaches them. An omittednamespacemeans the source action's package namespace, not the request's.@ForwardTargeton the class (not@Inherited, read from the class behind any proxy) orforward-target="true"on<action>. That attribute is the only grammar change, so it comes with a newstruts-7.6.dtd. Forwarding to an action that has not opted in, or to a name that only resolves throughdefault-action-ref, throws.@StrutsParameterrules, like a servlet forward.pass. They are read through bean getters, with no OGNL evaluation.@ForwardParameter, applied by the newforwardParamsinterceptor.forwardParamsruns directly afterparamsinbasicStack,defaultStack,paramsPrepareParamsStack(after the secondparams) and the REST and Bean Validation stacks.forwardParamsthrows.struts.forward.maxDepthdefaults to 5 and also holds across mixed forward/chain loops.ForwardConfigValidator):passnames fail startup in every mode.forwardParams, and cycles in the forward graph are logged at WARN, or fail startup in devMode.foo→foo-bartransfer becomes aforwardwhenfoo-barhas opted in.@Result(type = "forward")works.tokenSession. Replaying a duplicate submit renders the forward target's result against the target's stack, and never re-runs a target that rendered nothing.Decisions beyond the design doc
foo-barthat has not opted in, so existing Convention apps keep working untilchainis removed in 8.0.0. A package that does not extendstruts-defaultalso keeps the chain.forwardresults only. An implicit forward always goes fromfooto the longerfoo-bar, so implicit forwards alone cannot form a cycle.basicStackgetsforwardParamstoo.passnames, besides cycles.ActionForwardResultisfinal, so detecting forward results by class name stays exact.forward(ActionForwardResult)forward-target@ForwardTargetand@ForwardParameterpassforwardParamsstruts.forward.maxDepthNew public API (all
@since 7.6.0)org.apache.struts2.result.ActionForwardResult,NestedActionResultorg.apache.struts2.forward.ForwardTarget,ForwardParameter,ForwardTargets,ForwardContext,ForwardConfigValidatororg.apache.struts2.interceptor.ForwardParametersInterceptorActionInvocation#getResultInvocation(): a default method returningthis.DefaultActionInvocationreturns the innermost forwarded invocation.ProxyService#ultimateTargetClassOf(Class<?>): a default method returning the argument.StrutsProxyServiceunwraps Spring/CGLIB proxy classes. It has a distinct name, not an overload, so existingany()call sites and stubs keep binding toultimateTargetClass(Object).Behaviour notes for the docs (struts-site PR to follow)
forwardis notdispatcher.dispatcheris a servlet forward to a resource.prepare(), becauseforwardParamsruns afterprepare.token/tokenSessionon the source. WithexecAndWaiton the target, every poll re-runs the source.chainaccepts, such asskipActions, fail on aforwardresult.chain, step by step:passfor the values the source must hand over.type="chain"totype="forward".chaininterceptor reference.Testing
./mvnw test -DskipAssemblyon core: 3948 tests, 0 failures. Convention: 102. REST: 253. Spring: 61. Bean Validation: 26.🤖 Generated with Claude Code