couchbase/couchbase-lite-java-core — pull request #195 by mjq (2014-05-06 22:24:31+00:00)
Title: 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.

I chose this in favour of synchronizing Manager.getDatabase because these alone should help fix similar issues in other places (e.g. Manager.getExistingDatabase).