Skip to content

WW-5701 Compare the conversion marker by identity, not equals (6.x backport) - #1879

Open
lukaszlenart wants to merge 2 commits into
support/struts-6-x-xfrom
WW-5701-collection-converter-identity-6x
Open

WW-5701 Compare the conversion marker by identity, not equals (6.x backport)#1879
lukaszlenart wants to merge 2 commits into
support/struts-6-x-xfrom
WW-5701-collection-converter-identity-6x

Conversation

@lukaszlenart

Copy link
Copy Markdown
Member

Backport of #1874 to the 6.x line.

NO_CONVERSION_POSSIBLE is an ordinary String constant, so CollectionConverter's
!NO_CONVERSION_POSSIBLE.equals(convertedValue) guard also matched a successfully converted element
whose own text happens to be "ognl.NoConversionPossible" — and silently dropped it. Only the constant
instance itself signals a failed conversion, so the comparison is now by identity.

Verified affected on 6.x before fixing: testElementWhoseTextEqualsTheMarkerIsKept fails on
support/struts-6-x-x with expected:<[alpha, ognl.NoConversionPossible, omega]> but was:<[alpha, omega]>.

Note on the fixture, because it is easy to get wrong: the test value is built at runtime with
new String(...toCharArray()) and guarded by assertNotSame. A String literal is interned to the very
same instance as the constant, so a literal-based test would pass vacuously even against the unfixed code.
No request-derived parameter is ever that instance — a servlet container builds parameter values from the
request bytes.

The companion test pins that the guard still works: a genuinely unconvertible element is still dropped.

Full core suite green: 2719 tests, 0 failures.

Fixes WW-5701

🤖 Generated with Claude Code

lukaszlenart and others added 2 commits August 27, 2026 18:20
…ot equals

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

NO_CONVERSION_POSSIBLE is an ordinary String constant, so comparing with
equals() also matched a genuinely converted element whose own text happens
to be "ognl.NoConversionPossible" - and silently dropped it from the
collection. Only the constant instance itself signals a failed conversion,
so compare by identity.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…e guard paths

Backport of the coverage tests added on main, where the Sonar quality gate
failed at 77.8% coverage of new code: the marker guard was only exercised on
the array-source path, leaving the false branch of the other two guards
uncovered.

Both added paths are reachable from a request - a Set-typed property fed from
a List, and a single-valued parameter assigned to a collection property. The
single-value holder is seeded before the assignment so that a setter which is
never called cannot make the test pass vacuously.

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