DATACOUCH-462 - ReactiveCouchbaseRepository count() will raise exception when bucket is empty.

Small cleanup in the deleteAll test (which actually tests this as well), while
we are there.

Also, removed an unused import
This commit is contained in:
David Kelly
2019-06-28 10:21:41 -06:00
committed by GitHub
parent 64a91f1eb6
commit 4341edf941
2 changed files with 9 additions and 13 deletions

View File

@@ -21,7 +21,6 @@ import java.io.Serializable;
import com.couchbase.client.java.document.json.JsonArray;
import com.couchbase.client.java.error.DocumentDoesNotExistException;
import com.couchbase.client.java.view.AsyncViewResult;
import com.couchbase.client.java.view.AsyncViewRow;
import com.couchbase.client.java.view.ViewQuery;
import org.reactivestreams.Publisher;
@@ -238,7 +237,8 @@ public class SimpleReactiveCouchbaseRepository<T, ID extends Serializable> imple
.queryView(query)
.flatMap(AsyncViewResult::rows)
.map(asyncViewRow ->
Long.valueOf(asyncViewRow.value().toString())).toSingle());
Long.valueOf(asyncViewRow.value().toString()))
.switchIfEmpty(Observable.just(0L)).toSingle());
}
@SuppressWarnings("unchecked")