Repository navigation
WW-5789 fix(rest): keep params-bound values when the body handler binds nothing - #2050
Merged
Merged
Conversation
…ds nothing Since WW-5626 (7.2.0), ContentTypeInterceptor runs a two-phase copy for every handler that is not AuthorizationAwareContentTypeHandler when struts.parameters.requireAnnotations=true: a fresh instance is built with the no-arg constructor, the handler fills it, and every non-null property is copied onto the real target. FormUrlEncodedHandler, MultipartFormDataHandler and HtmlHandler never touch the body, so the "fresh" instance holds only constructor defaults, and those overwrote the values ParametersInterceptor had bound one step earlier. Null defaults were skipped, which is why the report reads "works unless the field is null by default". The three handlers bind nothing, so they now declare the marker and take the direct path. The marker Javadoc admits that case and names the subclass caveat. Co-Authored-By: Claude Mythos 5.1 <noreply@anthropic.com>
lukaszlenart
marked this pull request as ready for review
October 22, 2026 20:01
|
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-5789
What was wrong
A ModelDriven action in a package extending
rest-defaultlost form-bound values on every model property that has a non-null constructor default, while JSON bodies andstruts.parameters.requireAnnotations=falseboth worked. Regression from 7.2.0.Since WW-5626,
ContentTypeInterceptorruns a two-phase copy for every handler that is not anAuthorizationAwareContentTypeHandlerwhenrequireAnnotations=true: build a fresh instance via the no-arg constructor, let the handler fill it, copy every non-null property onto the real target.FormUrlEncodedHandler,MultipartFormDataHandlerandHtmlHandlerhave a no-optoObject, so the fresh instance carried only constructor defaults, and those were copied over whatparamshad bound one interceptor earlier. Null defaults are skipped by the copy, which is exactly the reporter's "unless it is null by default".Change
AuthorizationAwareContentTypeHandler, so the interceptor takes the direct path for them. They bind nothing, so there is nothing to authorize after the fact.toObjectto deserialize inherits the declaration and must honor the context itself.ContentTypeInterceptorIntegrationTest: three tests on a ModelDriven fixture with a constructor default, one per handler. Each failed withexpected:<[bound-by-params]> but was:<[new]>before the change.Left out on purpose
The two-phase copy itself still cannot tell "the body said X" from "the constructor said X". A handler that stays on that path (
XStreamHandler, which is opt-in, and any third-party handler) still copies a constructor default over a params-bound orprepare()-loaded value whenever the body omits that property. Fixing that means comparing against a pristine fresh instance insidecopyAuthorizedProperties, which changes the semantics of the authorization copy. Tracked as WW-5790.Verification
plugins/restsuite with core compiled from the branch: 226 tests, 0 failures.🤖 Generated with Claude Code