mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-24 02:12:15 -05:00
Make sure semaphore in MessageProvider is released in case of an error
Patch provided by teslacoil
This commit is contained in:
parent
3171ee969f
commit
57e55734c4
@ -840,12 +840,19 @@ public class MessageProvider extends ContentProvider {
|
|||||||
String sortOrder) throws Exception {
|
String sortOrder) throws Exception {
|
||||||
mSemaphore.acquire();
|
mSemaphore.acquire();
|
||||||
|
|
||||||
final Cursor cursor;
|
Cursor cursor = null;
|
||||||
|
try {
|
||||||
cursor = mDelegate.query(uri, projection, selection, selectionArgs, sortOrder);
|
cursor = mDelegate.query(uri, projection, selection, selectionArgs, sortOrder);
|
||||||
|
} finally {
|
||||||
|
if (cursor == null) {
|
||||||
|
mSemaphore.release();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Android content resolvers can only process CrossProcessCursor instances */
|
/* Android content resolvers can only process CrossProcessCursor instances */
|
||||||
if (!(cursor instanceof CrossProcessCursor)) {
|
if (!(cursor instanceof CrossProcessCursor)) {
|
||||||
Log.w(K9.LOG_TAG, "Unsupported cursor, returning null: " + cursor);
|
Log.w(K9.LOG_TAG, "Unsupported cursor, returning null: " + cursor);
|
||||||
|
mSemaphore.release();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user