Closed Aloren closed 5 years ago
@BrianNichols i am not sure that this is an expected behavior, because code actually fails with NPE which is a bad sign. it is better to check for null and throw an exception with cause that an end user can understand quickly. who knows why Failed to read resource
happened? you need to go into code, check where original NPE happened and only after that you get that the file is missing (of course if you know that getResource
returns null for not found resource). i was working with that code and it was not obvious for me why the hell it can't read my file :D
if you wish i can move it inside try-catch block -- the contract with client will be still the same, but in case of missing file -- they will get a bonus (nice stacktrace with explanation message)
Ok, move the code block inside the try-catch block.
Fixed in Java client 4.4.0:
When the requested resource is not found, the old code throws an AerospikeException with "Failed to read resource \<resourcePath>" and lists the null pointer exception as the cause. This is an accurate representation of what is happening.
Throwing a different exception outside of the original try/catch block isn't worth it especially if getResource() itself throws an exception which now will not have the "Failed to read resource \<resourcePath>" message.