-
Notifications
You must be signed in to change notification settings - Fork 9
Description
The async collection getDocument
methods never complete exceptionally, even if there is an exception thrown -- for example, if deserialization fails.
The problem is at https://github.com/arangodb/arangodb-java-driver-async/blob/master/src/main/java/com/arangodb/internal/ArangoCollectionAsyncImpl.java#L132 and at https://github.com/arangodb/arangodb-java-driver-async/blob/master/src/main/java/com/arangodb/internal/ArangoCollectionAsyncImpl.java#L144 -- these methods assume result.complete
, even if response is null and ex
has a value.
Instead, these methods should be calling result.completeExceptionally(ex)
if ex
has a value.
The observed behavior with the current code is that errors at deserialization are swallowed, and presumably other errors such as temporary database errors, and to the application it looks like there is no issue, and a null was simply returned from the method.
An easy way to replicate this is:
MyDoc doc = new MyDoc(...);
collection.insertDocument(doc).join();
// set a breakpoint here, and modify some data in the db in an incompatible way
MyDoc result = collection.getDocument(doc._key, MyDoc.class, DocumentReadOptions()).join();
// the line above should throw an Exception, but instead it just sets result to null and silently ignores the data corruption
This is confusing, but worse -- suppressing exceptions like this is a recipe for downstream failures. For example, a db query failures due to the primary shard being unavailable, which could normally be handled by a retry if the exception was bubbled up normally, would simply return a null value to the application and the application will not be aware of any issue until much later when that null causes a user error or data corruption.