Skip to content

Circular references should be handled gracefully by equals #2519

@acarstoiu

Description

@acarstoiu

Currently, the equals matcher recurses for Maps and Iterables, but in a way that rejects circular references, while they are perfectly valid for certain applications.

The limit argument is a cap on recursive calls and, as simple as it is, it works fine. But the correct handling of circular references is not to recurse, but to compare by ==/identity. So, you should use a Set when walking the data so as to watch for repeated iterables and avoid the silly recursion.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions