org.knowm.xchange.dto.marketdata.Trade.hashCode()/equals() not Null-safe
See original GitHub issueTrade’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:
- Created 6 years ago
- Comments:11 (7 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.
Was fixed as part of attached commit