Skip to content

Different SimpleMap implementations are never equal #3669

@rschmitt

Description

@rschmitt

Description

An equality comparison between a SortedArrayStringMap and a JdkMapAdapterStringMap is guaranteed to return false:

public class JdkMapAdapterStringMap implements StringMap {
    @Override
    public boolean equals(final Object object) {
        if (object == this) {
            return true;
        }
        if (!(object instanceof JdkMapAdapterStringMap)) {
            return false;
        }
public class SortedArrayStringMap implements IndexedStringMap {
    @Override
    public boolean equals(final Object obj) {
        if (obj == this) {
            return true;
        }
        if (!(obj instanceof SortedArrayStringMap)) {
            return false;
        }

This is a bummer for unit testing, because otherwise identical maps can be considered unequal depending upon how they were constructed and whether they were copied or just wrapped. The recent efficiency changes in the context map implementation seem to have brought this problem to the fore; evidently there are cases now where immutable maps are wrapped whereas previously they would have been copied.

Metadata

Metadata

Assignees

Labels

apiAffects the public API

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    pFad - Phonifier reborn

    Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

    Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


    Alternative Proxies:

    Alternative Proxy

    pFad Proxy

    pFad v3 Proxy

    pFad v4 Proxy