Changes API with Cloudant : changes.hasNext() is true but changes.next() is null

22 views
Skip to first unread message

Foucauld Degeorges

unread,
Apr 24, 2015, 10:27:23 AM4/24/15
to light...@googlegroups.com
Hello,
I am using the following code from the Changes API documentation :

Changes changes = dbClient.changes()
.includeDocs(true)
.since(since)
.heartBeat(30000)
.continuousChanges();

while (changes.hasNext()) { 
ChangesResult.Row feed = changes.next();
String docId = feed.getId();
System.out.println(docID);
}
At first, the pre-existing changes are printed fine.
But when a new change happens while the thread is running, feed.getId() throws a NullPointerException because feed is null.
So this means changes.next() returned null right after changes.hasNext() returned true. That doesn't seem logical.
Is this a known bug, or am I doing something wrong ?

Thanks
Foucauld

PS : My database is an IBM Cloudant based on CouchDB, it it supposed to be 100% CouchDB-compatible and until now all other APIs work perfectly.

Ahmed Yehia

unread,
Apr 25, 2015, 11:05:46 AM4/25/15
to light...@googlegroups.com
This issue happens when Cloudant response returns an empty feed.

Fixed in a new release 0.1.8


On Friday, April 24, 2015 at 5:27:23 PM UTC+3, Foucauld Degeorges wrote:
Hello,
I am using the following code from a Changes API documentation :
Reply all
Reply to author
Forward
0 new messages