diff options
author | Christian Schneppe <christian@pix-art.de> | 2017-02-08 21:39:33 +0100 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2017-02-08 21:39:33 +0100 |
commit | 256bc64d314d403dc6b40549f687872963726f05 (patch) | |
tree | 1db2a84b633b7a89c1824d9592fd8ea55887832e /src/main/java/de/pixart | |
parent | cfa440d668dcd6605d2bb811bcc7d2a621752863 (diff) |
Stop Conversations force closing over sqlite errors due to long messages
Diffstat (limited to 'src/main/java/de/pixart')
3 files changed, 8 insertions, 2 deletions
diff --git a/src/main/java/de/pixart/messenger/entities/Message.java b/src/main/java/de/pixart/messenger/entities/Message.java index 8ac7735d6..5a3549a95 100644 --- a/src/main/java/de/pixart/messenger/entities/Message.java +++ b/src/main/java/de/pixart/messenger/entities/Message.java @@ -154,6 +154,8 @@ public class Message extends AbstractEntity { } } catch (InvalidJidException e) { jid = null; + } catch (IllegalStateException e) { + return null; // message too long? } Jid trueCounterpart; try { diff --git a/src/main/java/de/pixart/messenger/persistance/DatabaseBackend.java b/src/main/java/de/pixart/messenger/persistance/DatabaseBackend.java index b40452f1a..50519a2a7 100644 --- a/src/main/java/de/pixart/messenger/persistance/DatabaseBackend.java +++ b/src/main/java/de/pixart/messenger/persistance/DatabaseBackend.java @@ -597,8 +597,10 @@ public class DatabaseBackend extends SQLiteOpenHelper { cursor.moveToLast(); do { Message message = Message.fromCursor(cursor); - message.setConversation(conversation); - list.add(message); + if (message != null) { + message.setConversation(conversation); + list.add(message); + } } while (cursor.moveToPrevious()); } cursor.close(); diff --git a/src/main/java/de/pixart/messenger/services/ExportLogsService.java b/src/main/java/de/pixart/messenger/services/ExportLogsService.java index d7948d651..61d8a921d 100644 --- a/src/main/java/de/pixart/messenger/services/ExportLogsService.java +++ b/src/main/java/de/pixart/messenger/services/ExportLogsService.java @@ -119,6 +119,8 @@ public class ExportLogsService extends Service { BufferedWriter bw = null; try { for (Message message : mDatabaseBackend.getMessagesIterable(conversation)) { + if (message == null) + continue; if (message.getType() == Message.TYPE_TEXT || message.hasFileOnRemoteHost()) { String date = simpleDateFormat.format(new Date(message.getTimeSent())); if (bw == null) { |