Don't attempt to call db.setLastSequence if db closed

Added in reaction to seeing errors in logs: java.lang.IllegalStateException: attempt to re-open an already-closed object: SQLiteDatabase: /data/data/com.couchbase.lite.test/files/test/cblite-test.cblite
Don't call pendingSequences.first() if empty

Added in reaction to java.util.NoSuchElementException
Fixes #295 by checking if the db is null before calling forgetReplication.

https://github.com/couchbase/couchbase-lite-android/issues/295
fix NPE when calling Manager.getDatabase concurrently

Calling Manager.getDatabase() concurrently can lead to:

java.lang.NullPointerException
            at com.couchbase.lite.android.AndroidSQLiteStorageEngine.execSQL(AndroidSQLiteStorageEngine.java:95)
            at com.couchbase.lite.Database.initialize(Database.java:888)
            at com.couchbase.lite.Database.open(Database.java:918)
            at com.couchbase.lite.Manager.getDatabase(Manager.java:229)

This can be resolved by synchronizing
- Manager.getDatabaseWithoutOpening(), and
- Database.open().

The first ensures that both calls to getDatabase() get the same Database
object back, and the second ensures that a Database is only opened once.
Merge pull request #195 from mjq/get_database_crash

Fix NPE when calling Manager.getDatabase concurrently
Issue #296 Add logging to debug issue

https://github.com/couchbase/couchbase-lite-android/issues/296
Issue #296 Attempt to diagnose root cause by rethrowing unexpected exceptions

https://github.com/couchbase/couchbase-lite-android/issues/296
Revert "Issue #296 Add logging to debug issue"

This reverts commit 2a93a52f4dce45b4447c28a4180961f406a76eee.
Issue #296 Attempt to diagnose root cause by rethrowing unexpected exceptions

https://github.com/couchbase/couchbase-lite-android/issues/296
Issue #296 Add debugging

https://github.com/couchbase/couchbase-lite-android/issues/296
Issue #296 Add even more logging to debug issue

http://factory.couchbase.com/view/build/view/mobile_dev/view/android/job/build_cblite_android_master/356/

https://github.com/couchbase/couchbase-lite-android/issues/296
Fixes #296 by making sure request aborted properly

(cherry pick from unpushed master commit)

https://github.com/couchbase/couchbase-lite-android/issues/296

Conflicts:
	src/main/java/com/couchbase/lite/support/RemoteRequest.java
Revert "Issue #296 Add even more logging to debug issue"

This reverts commit abc7387de44481f98fb696f3718dc7eb9763c112.
Revert "Issue #296 Add debugging"

This reverts commit 46a823adba2115e70142431abcdf3937e013da99.
Revert "Issue #296 Attempt to diagnose root cause by rethrowing unexpected exceptions"

This reverts commit 523dbe121ec521e9791d2c58c3a9dc270754f948.
Revert "Issue #296 Attempt to diagnose root cause by rethrowing unexpected exceptions"

This reverts commit 9a536971e5a3a903cf5fade7b0c608ad190434bb.
Merge branch 'refs/heads/release/1.0.0'
Issue #296 Log calls to asyncStarted and asyncFinished

https://github.com/couchbase/couchbase-lite-android/issues/296
Issue #296 add debugging

https://github.com/couchbase/couchbase-lite-android/issues/296
Issue #296 add debugging

https://github.com/couchbase/couchbase-lite-android/issues/296