Skip to content

Fix ClassCastException in SoftAssertions with custom list assertions#4127

Open
HuitaePark wants to merge 1 commit intoassertj:mainfrom
HuitaePark:main
Open

Fix ClassCastException in SoftAssertions with custom list assertions#4127
HuitaePark wants to merge 1 commit intoassertj:mainfrom
HuitaePark:main

Conversation

@HuitaePark
Copy link

Modified containsExactlyInAnyOrderForProxy to accept a Collection instead of arrays. This prevents ClassCastException caused by strict array type checking in proxies.

  • Signature Change: ForProxy method now takes Collection.
  • New Utility: Added IterableUtil.toArrayList for safe conversion.
  • Test: Added SoftAssertions_proxied_AbstractListAssert_Test to verify the fix.

I have applied this fix only to containsExactlyInAnyOrder as a proof of concept.
Please confirm if this direction is correct. Once approved, I will apply this pattern to all other affected methods (e.g.,ForProxy).

Check List:

Changed `containsExactlyInAnyOrderForProxy` signature to accept Collection instead of arrays.
This prevents ClassCastException caused by strict array type checking in proxies.

Fixes assertj#3797
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.

Calling final methods through a custom assertion, which is inherited from AbstractListAssert, results in a java.lang.ClassCastException

1 participant