Repository navigation
WW-5819 Log a validator param that fails type conversion - #2062
Open
lukaszlenart wants to merge 2 commits into
Open
lukaszlenart wants to merge 2 commits into
lukaszlenart wants to merge 2 commits into
Conversation
…sion A validator param that cannot be converted to its property type is still left unset, but is now logged with the validator class, param, value and cause: WARN by default, ERROR in devMode. Params without a writable property (e.g. the annotation builder's methodName routing key) stay silent, as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
lukaszlenart
marked this pull request as ready for review
October 26, 2026 11:56
Contributor
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
5 open issues
messagesandlevelsare maintained as two separateCopyOnWriteArrayLists, but updates to them… · Newmessagesandlevelsare maintained as two separateCopyOnWriteArrayLists, but updates to them… · Neworg.apache.logging.log4j.Levelis not an enum, so comparing with==relies on reference… · New The log reportsclassNamepassed intobuildValidator, which may not match the runtime validator… · New UsingStream#toList()requires JDK 16+. If this project/module still targets JDK 8/11 for tests,… · New
What changed in this PR
This PR improves observability for Struts validator configuration by logging validator params that fail type conversion during validator construction (without changing existing runtime behavior).
Changes:
- Set validator params individually and log failed type conversions at WARN (or ERROR in devMode)
- Add test coverage validating log level behavior and non-logging cases
- Extend
LogCapturetest utility to filter captured logs byLevel
| File | Description |
|---|---|
| core/src/main/java/org/apache/struts2/factory/DefaultValidatorFactory.java | Sets params one-by-one and logs conversion failures with devMode-dependent severity |
| core/src/test/java/org/apache/struts2/factory/DefaultValidatorFactoryTest.java | Adds tests asserting new logging behavior and ensuring validator still builds |
| core/src/test/java/org/apache/struts2/test/LogCapture.java | Captures log levels and adds messages(Level) filtering for assertions |
Review effort: Lite
…ture Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot stopped reviewing on behalf of
lukaszlenart due to an error
October 26, 2026 13:23
|
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-5819
Summary
A validator param that cannot be converted to its property type used to be left unset with no trace. For a range bound that silently switches the check off:
DefaultValidatorFactory.buildValidatornow sets each param separately and logs a failed one with the validator class, param, value and cause — WARN by default, ERROR in devMode. Behaviour is unchanged: the validator is still built and the param stays unset. Failing the configuration instead is WW-5818 (8.0.0).Design notes
methodNamerouting param (read byDefaultActionValidatorManager) that no validator has a setter for; logging every failed set would have put a WARN on every annotated validator. Misspelled param names therefore stay silent, as before — that belongs with WW-5818.XWorkConverterdiscards theTypeConversionExceptionand returnsNO_CONVERSION_POSSIBLE, so the cause seen here is e.g.NoSuchMethodException: ...setMin(java.lang.String). Surfacing the converter message would need a change inXWorkConverter, out of scope.setProperty(..., true)) bypassesOgnlUtil's generic devMode WARN, so nothing is logged twice. The evaluation path (OGNL context, root, member access) is the same assetProperties.LogCapturegained amessages(Level)overload; existing callers are unaffected.The core suite surfaced one real case:
SimpleAnnotationActiondeclares@DateRangeFieldValidator(min = "-1", max = "99"), whose bounds were always ignored. Left as is.Test plan
DefaultValidatorFactoryTest: WARN by default, ERROR in devMode, valid value not logged, param without a property not loggedmvn test -DskipAssembly -pl core— 3620 tests, 0 failures🤖 Generated with Claude Code