cloudant / sync-android

A JSON-based document datastore for Android applications
Apache License 2.0
267 stars 90 forks source link

Fix exception when replicating with CouchDB 2.3 #594

Closed jjrodrig closed 5 years ago

jjrodrig commented 5 years ago

Checklist

Description

Fixes #593

This PR fixes an exception when parsing the response to GET /db on the remote server when replication with CouchDB 2.3

Approach

CouchDB 2.3 has changed purge_seq type from long to a String, similar to the update_seq. This affects to the parsing of the GET /db operation on the remote database as the parsing is failling.

This PR changes the type of purgeSeq property from long to String in com.cloudant.sync.internal.mazha.CouchDbInfo

Schema & API Changes

Security and Privacy

Testing

I've not added tests for this change. Existing replication tests where failing with CouchDB 2.3 and this PR allows to pass them successfully.

There is not infrastructure in the project for automating testing over different CouchDB versions, so I have configure a travis build for testing this change over three CouchDB version 2.3, 2.1.2 and 1.7.4. The result is here https://travis-ci.org/jjrodrig/sync-android/builds/475100353

Monitoring and Logging

willholley commented 5 years ago

Just a note that in Cloudant,purge_seq is a long (as with previous versions of CouchDB), so we'd need to test that long values are correctly converted to strings during deserialisation.

jjrodrig commented 5 years ago

@willholley I've added a test for deserializing a pre-2.3 DB Info response into new CouchDBInfo class with purge_seq as String.

Fenil15 commented 5 years ago

@willholley When is the next release of 2.4.0 as I am also affected by this change? I have the library sources and able to add the project locally. Is the current master branch stable and can it be used for my production app or should i await for the stable release?

ricellis commented 5 years ago

We are planning to do a release that includes this fix in the near future.

You can obtain snapshot builds from the repository at https://oss.sonatype.org/content/repositories/snapshots - this change is available in 2.3.1-SNAPSHOT builds since timestamp 20190111.115806-3

We would only recommend using released versions in production.