algorand / algorand/java-algorand-sdk

Correctness: Overriding equals, but not hashCode

未关闭
#344 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
bug good first issue Team Lamprey
主要语言
Java
星标
73
派生
71
平均合并
41 分钟
30 天内合并 PR
2

描述

### Subject of the issue

While working on https://github.com/algorand/java-algorand-sdk/pull/340#discussion_r912043589, I observed numerous instances where `equals` is overwritten, but not `hashCode`.

The status quo breaks `hashCode`'s contract as discussed in https://stackoverflow.com/questions/2265503/why-do-i-need-to-override-the-equals-and-hashcode-methods-in-java.

### Your environment

N/A

### Steps to reproduce
N/A

### Expected behaviour

There's at least 2 solutions:
* Immediately - Consistently override `hashCode` and `equals`. Prefer using an IDE-generated implementation.
* Longer term - Upgrade to >= JDK 16 and replace class definitions with records (https://docs.oracle.com/en/java/javase/16/language/records.html). Among other benefits, records obviate the need to manage `equals` and `hashCode` implementations.

### Actual behaviour
N/A

# Acceptance Criteria
1. Updating hand written code to implement both functions.
2. Update code generator to generate hashCode along with equals, then regenerate the code.

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。