-
-
Notifications
You must be signed in to change notification settings - Fork 452
Open
Labels
bugAn unexpected problem or unintended behavior of the CoreAn unexpected problem or unintended behavior of the Core
Description
Java requires that equals()
and hashCode()
must be consistent, two objects that are "equal" must always produce the same hash code.
Failing to respect this will make things go wrong with HashMap
, HashTable
etc., i.e. some of the core Java building blocks that many other things build upon.
I've seen that this is implemented wrong in some of the Yaml
classes, e.g:
Lines 40 to 55 in 6f7d46c
@Override | |
public int hashCode() { | |
return Objects.hash(getValue()); | |
} | |
@Override | |
public boolean equals(@Nullable Object obj) { | |
if (this == obj) { | |
return true; | |
} else if (obj == null || getClass() != obj.getClass()) { | |
return false; | |
} | |
YamlMetadataDTO other = (YamlMetadataDTO) obj; | |
return Objects.equals(getValue(), other.getValue()) && YamlElementUtils.equalsConfig(config, other.config); | |
} | |
} |
Similar errors exist in YamlChannelDTO
and YamlThingDTO
.
Metadata
Metadata
Assignees
Labels
bugAn unexpected problem or unintended behavior of the CoreAn unexpected problem or unintended behavior of the Core