java-bigchaindb-driver icon indicating copy to clipboard operation
java-bigchaindb-driver copied to clipboard

NPE in TransactionsApi.getTransactionById() if transaction does not exist

Open marcin-kamionowski opened this issue 7 years ago • 9 comments

Driver version: 1.1 and master(cae61d81ad021aa8eb29830f87cdac7f2d8f10ab) Response: {"message":"Not found","status":404} Stacktrace:

Exception in thread "main" java.lang.NullPointerException at com.bigchaindb.json.strategy.TransactionDeserializer.deserialize(TransactionDeserializer.java:50) at com.bigchaindb.json.strategy.TransactionDeserializer.deserialize(TransactionDeserializer.java:23) at com.google.gson.internal.bind.TreeTypeAdapter.read(TreeTypeAdapter.java:69) at com.google.gson.Gson.fromJson(Gson.java:888) at com.google.gson.Gson.fromJson(Gson.java:853) at com.google.gson.Gson.fromJson(Gson.java:802) at com.google.gson.Gson.fromJson(Gson.java:774) at com.bigchaindb.util.JsonUtils.fromJson(JsonUtils.java:133) at com.bigchaindb.api.TransactionsApi.getTransactionById(TransactionsApi.java:74)

marcin-kamionowski avatar Sep 04 '18 09:09 marcin-kamionowski

Hi, I would like to take up this issue. Kindly let me know if help is still required.

kai18 avatar Oct 14 '18 10:10 kai18

@kai18 sure. any help is most welcome. Thanks for your contribution. Once you have fixed this issue. Send a PR to this repo. Cheers!

innopreneur avatar Oct 14 '18 10:10 innopreneur

@innoprenuer Thanks! Just so we are clear, there needs to be an exception hierarchy that forces the user to handle this particular scenario. Right? That is what we are expecting here?

kai18 avatar Oct 14 '18 10:10 kai18

@kai18 This exception happens because we are expecting valid transaction object but in case of valid response (404, 500) we don't get transaction object and so deserialization doesn't work as there is no check for error codes. So, solution should go somewhere here - take a look here. We can maybe check for error codes and throw 'TransactionNotFound' exception if error code is 404.

innopreneur avatar Oct 14 '18 10:10 innopreneur

@innoprenuer Thanks for the confirmation! I have raised the PR. Please review and let me know of any changes. https://github.com/bigchaindb/java-bigchaindb-driver/pull/38

kai18 avatar Oct 14 '18 13:10 kai18

@innoprenuer Adding this checked exception breaks backwards compatibility, as, when people upgrade, they'll be forced to handle this exception. I was just wondering, maybe we should do this across APIs in a single go? If that's the case, please let me know of any changes in my current PR, and I can do the same for all APIs

kai18 avatar Oct 15 '18 10:10 kai18

@ttmc @innoprenuer Is this project still under active development?

kai18 avatar May 17 '19 08:05 kai18

See https://medium.com/ipdb-blog/ipdb-foundation-assumes-governance-of-bigchaindb-software-and-testnet-51235322e14c

ttmc avatar May 17 '19 09:05 ttmc

thanks for the info @ttmc

kai18 avatar May 23 '19 07:05 kai18