bitcoinj-cash / bitcoinj

A library for working with Bitcoin
http://bitcoinj.cash
Apache License 2.0
66 stars 35 forks source link

Prevent hasTransactions returning null #74

Closed brad1121 closed 5 years ago

brad1121 commented 6 years ago

non-critical but avoids an extra unnecessary null check/exception which annoyed me at one point.

HashEngineering commented 6 years ago

How does hasTransactions return null?

It would be helpful to see the call stack of such a case.

Android Studio does point out that List.isEmpty() can produce a NullPointerException.

the original method says: !this.transactions.isEmpty(); and it is possible that this transactions = null in the case that the block contains only the header. Not sure if this is related to my question.

brad1121 commented 6 years ago

Yea that would be it, block with only headers returns null. I think its cleaner it return false.

coveralls commented 6 years ago

Coverage Status

Coverage increased (+0.01%) to 76.877% when pulling faa0ce77b5ed646b27ed3326d1a7202cf2dacaa5 on brad1121:hasTransactionsPatch into df9b8a812d6a66bafe7b7b6224271d2bf99f0961 on bitcoinj-cash:cash-0.14.

HashEngineering commented 6 years ago

https://github.com/bitcoinj/bitcoinj/commit/73fe9e6ab51501d498cf1a970aca208ea049adff

Danconnolly commented 5 years ago

Migrated to Bitcoin SV library.