Querying documents with invalid ID never completes
fritzfranzke opened this issue · comments
Describe the bug
I am querying the database for documents using the example from the README. This works fine as long a document with the specified ID exists. However, if no document exists, the call never completes.
To Reproduce
Add a document with ID X
to the database test
. Execute the following code:
GetDocumentOptions getDocOptions = new GetDocumentOptions.Builder()
.db("test")
.docId("X")
.build();
Document documentExample = client
.getDocument(getDocOptions)
.execute()
.getResult();
This should return the document. Calling the same code with docId
set to Y
doesn't return anything, but also never finishes, making error handling impossible.
Must gather (please complete the following information):
- SDK Version
0.4.2
- Java Version
17.0.6 (2023-01-17)
Additional context
I am using the SDK with Apache CouchDB.
Am misunderstanding the API, or are there some flags I need to set for this to work?
Thanks for the great work!
A document ID that doesn't exist should cause the DB to return a 404
and the SDK should throw com.ibm.cloud.sdk.core.service.exception.NotFoundException
. This works fine for me with 0.4.2
.
Probably worth noting that NotFoundException
is a RuntimeException
. If you copied the README example then there is an explicit catch block for it.
Indeed, wrapping in a try-catch
works as you described.
Thanks for the quick support and sorry for not reading the docs more thoroughly :/