java-bigchaindb-driver
java-bigchaindb-driver copied to clipboard
NPE in TransactionsApi.getTransactionById() if transaction does not exist
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)
Hi, I would like to take up this issue. Kindly let me know if help is still required.
@kai18 sure. any help is most welcome. Thanks for your contribution. Once you have fixed this issue. Send a PR to this repo. Cheers!
@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 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.
@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
@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
@ttmc @innoprenuer Is this project still under active development?
See https://medium.com/ipdb-blog/ipdb-foundation-assumes-governance-of-bigchaindb-software-and-testnet-51235322e14c
thanks for the info @ttmc