couchbase/couchbase-lite-android-core — pull request #30 by mjq (2014-01-22 23:49:02+00:00)
Title: Always close response stream in ChangeTracker

In the ChangeTracker's run method, the response stream is sometimes left unclosed.

When ChangeTrackerMode is LongPoll, the stream is closed after it has been read with ObjectMapper.readValue(). But, in the OneShot case, the stream is never closed, since the JsonParser never reaches the end of the stream.

It might be possible for the LongPoll case to leak too if an error is thrown, but I'm not sure. To be safe, I've wrapped both cases in a try/finally block that ensures the stream is always closed.

Found while investigating couchbase/couchbase-lite-android#176. Might be a contributing cause of those thread leaks.