From 6d678540860db8aa4c675645033cb604e44866b3 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Tue, 13 Nov 2018 09:58:28 +0100 Subject: [PATCH] catch cursor window allocation exception --- .../conversations/persistance/DatabaseBackend.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java b/src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java index f2c2a6e00..d5c9153b7 100644 --- a/src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java +++ b/src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java @@ -647,17 +647,23 @@ public class DatabaseBackend extends SQLiteOpenHelper { db.insert(RESOLVER_RESULTS_TABLENAME, null, contentValues); } - public Resolver.Result findResolverResult(String domain) { + public synchronized Resolver.Result findResolverResult(String domain) { SQLiteDatabase db = this.getReadableDatabase(); String where = Resolver.Result.DOMAIN + "=?"; String[] whereArgs = {domain}; final Cursor cursor = db.query(RESOLVER_RESULTS_TABLENAME, null, where, whereArgs, null, null, null); Resolver.Result result = null; if (cursor != null) { - if (cursor.moveToFirst()) { - result = Resolver.Result.fromCursor(cursor); + try { + if (cursor.moveToFirst()) { + result = Resolver.Result.fromCursor(cursor); + } + } catch (Exception e ) { + Log.d(Config.LOGTAG,"unable to find cached resolver result in database "+e.getMessage()); + return null; + } finally { + cursor.close(); } - cursor.close(); } return result; }