question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

org.knowm.xchange.dto.marketdata.Trade.hashCode()/equals() not Null-safe

See original GitHub issue

Trade’s id may be null, e.g. in OKCoin’s trade history a orderId is provided, but no tradeId.

Trade doesn’t null-check the tradeId at hashCode() or equals(). Calling these methods on OkCoin’s trade history item raises a NullPointerException.

public int hashCode() { return id.hashCode(); }

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:11 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
schabe77commented, Oct 12, 2017

My example order is a trade - it’s fully filled. It just seems that OkCoin doesn’t provide trade ids.

And again: even if there is no trade id, I don’t want to run into a NullPointerException. Usage of id should be null-safe in Trade.

0reactions
earcecommented, Feb 27, 2021

Was fixed as part of attached commit

Read more comments on GitHub >

github_iconTop Results From Across the Web

Trade (XChange 5.0.14 API) - Knowm.org
declaration: package: org.knowm.xchange.dto.marketdata, class: Trade. ... timestamp of the trade according to the exchange's server, null if not provided.
Read more >
Dealing with null - EqualsVerifier - Jan Ouwens
For safety, EqualsVerifier requires you to add null checks for non-primitive fields you reference in your equals or hashCode method. If you don't, ......
Read more >
Java null check why use == instead of .equals() - Stack Overflow
They're two completely different things. == compares the object reference, if any, contained by a variable. .equals() checks to see if two objects...
Read more >
Bug descriptions — spotbugs 4.7.3 documentation
This implementation of equals(Object) violates the contract defined by java.lang.Object.equals() because it does not check for null being passed as the argument ...
Read more >
Objects (Java Platform SE 8 ) - Oracle Help Center
Returns the hash code of a non- null argument and 0 for a null argument. ... @Override public int hashCode() { return Objects.hash(x,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found