From 9271bc0f9ec17387e91f7d5e2980d073ac67cb82 Mon Sep 17 00:00:00 2001 From: Christian Schneppe Date: Wed, 25 Jan 2017 19:52:50 +0100 Subject: make sure to properly stop tagwriter --- src/main/java/de/pixart/messenger/xml/TagWriter.java | 7 +++++++ src/main/java/de/pixart/messenger/xml/XmlReader.java | 2 +- src/main/java/de/pixart/messenger/xmpp/XmppConnection.java | 4 +++- 3 files changed, 11 insertions(+), 2 deletions(-) (limited to 'src/main/java/de/pixart/messenger') diff --git a/src/main/java/de/pixart/messenger/xml/TagWriter.java b/src/main/java/de/pixart/messenger/xml/TagWriter.java index 0a663ce1b..c96841d56 100644 --- a/src/main/java/de/pixart/messenger/xml/TagWriter.java +++ b/src/main/java/de/pixart/messenger/xml/TagWriter.java @@ -99,6 +99,13 @@ public class TagWriter { public void forceClose() { finish(); + if (outputStream != null) { + try { + outputStream.close(); + } catch (IOException e) { + //ignoring + } + } outputStream = null; } } diff --git a/src/main/java/de/pixart/messenger/xml/XmlReader.java b/src/main/java/de/pixart/messenger/xml/XmlReader.java index 3c8cfa1f2..efd4dcc95 100644 --- a/src/main/java/de/pixart/messenger/xml/XmlReader.java +++ b/src/main/java/de/pixart/messenger/xml/XmlReader.java @@ -82,7 +82,7 @@ public class XmlReader { } } catch (Throwable throwable) { - throw new IOException("xml parser mishandled " + throwable.getClass().getName(), throwable); + throw new IOException("xml parser mishandled " + throwable.getClass().getSimpleName() + "(" + throwable.getMessage() + ")", throwable); } finally { if (wakeLock.isHeld()) { try { diff --git a/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java b/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java index 883df52d8..7a8e3cfe2 100644 --- a/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java +++ b/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java @@ -1386,6 +1386,9 @@ public class XmppConnection implements Runnable { } private void forceCloseSocket() { + if (tagWriter != null) { + tagWriter.forceClose(); + } if (socket != null) { try { socket.close(); @@ -1405,7 +1408,6 @@ public class XmppConnection implements Runnable { interrupt(); Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": disconnecting force=" + Boolean.valueOf(force)); if (force) { - tagWriter.forceClose(); forceCloseSocket(); } else { if (tagWriter.isActive()) { -- cgit v1.2.3