Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maps containing nulls can be incorrectly considered equal #2913

Closed
ahgittin opened this issue May 25, 2023 · 1 comment · Fixed by #2914
Closed

Maps containing nulls can be incorrectly considered equal #2913

ahgittin opened this issue May 25, 2023 · 1 comment · Fixed by #2914
Milestone

Comments

@ahgittin
Copy link

TestNG Version

Note: only the latest version is supported

All known (confirmed in 7.3.0 and in master branch as at 25 May 2023)

Expected behavior

If two maps contain different keys, they should never be reported as equal.

Actual behavior

If two maps contain different keys, if the values for all such keys in the LHS map are null, they are reported as equal.

Is the issue reproducible on runner?

Everywhere I believe.

Test case sample

Please, share the test case (as small as possible) which shows the issue

    Map<String,Object> map1 = new LinkedHashMap<>();
    map1.put("a", 1);
    map1.put("b", null);
    Map<String,Object> map2 = new LinkedHashMap<>();
    map2.put("a", 1);
    map2.put("c", null);

    Assert.assertEquals(map1, map2);

The above assertion passes, but clearly it shouldn't.

Contribution guidelines

Incase you plan to raise a pull request to fix this issue, please make sure you refer our Contributing section for detailed set of steps.

I will open a fix shortly.

@ahgittin ahgittin mentioned this issue May 25, 2023
3 tasks
@ahgittin
Copy link
Author

Fixed by PR #2914

Test case checkMapNotEqualsWithNull added failing in 7a4394b passing once fixed applied in 4216a3d .

@krmahadevan krmahadevan added this to the 7.9.0 milestone May 30, 2023
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 a pull request may close this issue.

2 participants