Skip to content

WW-5700 Skip the store when a map or list element cannot be converted (6.x backport) - #1878

Open
lukaszlenart wants to merge 1 commit into
support/struts-6-x-xfrom
WW-5700-no-conversion-possible-guard-6x
Open

WW-5700 Skip the store when a map or list element cannot be converted (6.x backport)#1878
lukaszlenart wants to merge 1 commit into
support/struts-6-x-xfrom
WW-5700-no-conversion-possible-guard-6x

Conversation

@lukaszlenart

Copy link
Copy Markdown
Member

Backport of #1873 to the 6.x line.

When XWorkConverter cannot convert a value it returns the marker string NO_CONVERSION_POSSIBLE
("ognl.NoConversionPossible"). XWorkMapPropertyAccessor and XWorkListPropertyAccessor stored that
marker straight into the target collection, so a Map<Long, Integer> could be left holding the marker
String — under a String key, when the key was the unconvertible half — and the next read of that
collection failed with a ClassCastException far from the cause. The accessors now skip the assignment
and log at debug instead.

Verified affected on 6.x before fixing: all four tests below fail on support/struts-6-x-x with
ognl.NoConversionPossible found in the typed collection, and pass with the fix.

  • XWorkMapPropertyAccessorTest — value half and key half
  • XWorkListPropertyAccessorTest — indexed element
  • ParametersInterceptorTest — end to end through parameter binding, using the real-world trigger
    (an unchecked s:checkbox with submitUnchecked="true" submits "false" into a Map<Long, Integer>)

XWorkCollectionPropertyAccessor is deliberately left alone, as on main: its scalar setProperty is
not reachable through the value stack, so no failing test can be written for it.

Full core suite green: 2721 tests, 0 failures.

Fixes WW-5700

🤖 Generated with Claude Code

…e converted

Backport of the 7.4.0 fix (#1873) to the 6.x line.

When XWorkConverter cannot convert a value it returns the marker string
NO_CONVERSION_POSSIBLE. The map and list property accessors stored that
marker straight into the target collection, so a Map<Long, Integer> could
end up holding the String "ognl.NoConversionPossible" under a String key,
and the next read of that collection failed with a ClassCastException far
from the cause. Skip the assignment instead and log at debug.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

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