Closed sevokn closed 7 years ago
The limitation is documented
It is only valid to call build() after adding one or more requests. If parameters have been set but the request has not been added then an IllegalStateException will be thrown.
But yes, there is a bug where we should by throwing the IllegalStateException earlier.
When using a
ViewMultipleRequest
, the individual queries are separated by a call toadd()
.If no actual
add()
call is performed (the set of queries to be executed in this multiple request is empty), the java-cloudant library crashes with aNullPointerException
when executing the query, i.e. callinggetViewResponses()
.Exception in thread "main" java.lang.NullPointerException at com.cloudant.client.internal.views.ViewMultipleRequester.getViewResponses(ViewMultipleRequester.java:47)
Tested with version 2.9.0.
Another question then is in what way to fix this. Should java-cloudant silently accept these zero queries, perform these zero queries (= i.e. no http call to Cloudant), and return an empty result list? Or should an exception be thrown that the query is malformed? Or should Cloudant be queried in every case, returning whatever Cloudant returns (empty result set or error)? Anyways, the current behaviour is broken.