Skip to content

Stop using GetHashCode() in PropertyNameMarker #1029

Closed
@cdeutsch

Description

@cdeutsch

Ran into a weird bug today where I suddenly started getting the error:
"System.ArgumentException: An item with the same key has already been added."

Tracked it back to a GetHashCode() collision in PropertyNameMarker.cs
https://github.com/elasticsearch/elasticsearch-net/blob/develop/src/Nest/Domain/Marker/PropertyNameMarker.cs#L63

...when ElasticTypeConvert.cs is building a Dictionary<PropertyNameMarker, IElasticType> :
https://github.com/elasticsearch/elasticsearch-net/blob/1.2.1/src/Nest/Resolvers/Converters/ElasticTypeConverter.cs#L183

I'm not sure why you need to use GetHashCode() here. Seems like the "Name" property should already be unique.

Here are the two Names that are colliding for me.
-508464000
-509414400

Both strings return: -1595685939

https://www.dropbox.com/s/dx5349ppkimj7ov/Screenshot%202014-10-30%2021.51.46.png?dl=0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions