eclipse-tradista / tradista

Tradista: the first open source Financial Risk Management Solution
Apache License 2.0
9 stars 2 forks source link

Inconsistent hashCode implementation for Trades #96

Closed oasuncion closed 8 months ago

oasuncion commented 8 months ago

hashCode is inconsistent for Trade objects. Two trade objects with same positive id will have a different hashCode, and this is having bad side effects, for example when objects are retrieved from hash maps using trades as keys. Indeed, trade objects with same positive ids will be equal, so they should also have the same hashCode to avoid such inconsistencies.

To Reproduce Steps to reproduce the behavior:

  1. Have a code snippet with two trade objects (A and B), having the same positive id.
  2. Create a HashMap and add an entry with A as key and the "OK" String as value
  3. Call get(B) on the map

Expected behavior Calling get(B) on the map is expected to return "OK" and not null.

Environment :

oasuncion commented 8 months ago

It will be tested with ticket #91

oasuncion commented 8 months ago

Tested with ticket #91, it is OK.