diff options
author | Daniel Gultsch <daniel@gultsch.de> | 2016-06-13 19:05:32 +0200 |
---|---|---|
committer | Daniel Gultsch <daniel@gultsch.de> | 2016-06-13 19:05:32 +0200 |
commit | 40f81f19dfbfd806a604012fc1aa2eafb4e10cfe (patch) | |
tree | 6739bb76b718b2aa902659f0ee8ec6a3ff325db6 /src/main/java | |
parent | 587fb3cca327a3422c3fc7bfd7f16dcf8b33487d (diff) |
make sure tagwriter is clear before force closing socket
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/eu/siacs/conversations/xml/TagWriter.java | 26 | ||||
-rw-r--r-- | src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java | 2 |
2 files changed, 9 insertions, 19 deletions
diff --git a/src/main/java/eu/siacs/conversations/xml/TagWriter.java b/src/main/java/eu/siacs/conversations/xml/TagWriter.java index f11c1846..9d16c338 100644 --- a/src/main/java/eu/siacs/conversations/xml/TagWriter.java +++ b/src/main/java/eu/siacs/conversations/xml/TagWriter.java @@ -9,7 +9,6 @@ import eu.siacs.conversations.xmpp.stanzas.AbstractStanza; public class TagWriter { - private OutputStream plainOutputStream; private OutputStreamWriter outputStream; private boolean finshed = false; private LinkedBlockingQueue<AbstractStanza> writeQueue = new LinkedBlockingQueue<AbstractStanza>(); @@ -24,15 +23,9 @@ public class TagWriter { } try { AbstractStanza output = writeQueue.take(); - if (outputStream == null) { - shouldStop = true; - } else { - outputStream.write(output.toString()); - outputStream.flush(); - } - } catch (IOException e) { - shouldStop = true; - } catch (InterruptedException e) { + outputStream.write(output.toString()); + outputStream.flush(); + } catch (Exception e) { shouldStop = true; } } @@ -46,17 +39,9 @@ public class TagWriter { if (out == null) { throw new IOException(); } - this.plainOutputStream = out; this.outputStream = new OutputStreamWriter(out); } - public OutputStream getOutputStream() throws IOException { - if (this.plainOutputStream == null) { - throw new IOException(); - } - return this.plainOutputStream; - } - public TagWriter beginDocument() throws IOException { if (outputStream == null) { throw new IOException("output stream was null"); @@ -111,4 +96,9 @@ public class TagWriter { public boolean isActive() { return outputStream != null; } + + public void forceClose() { + finish(); + outputStream = null; + } } diff --git a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java index 928d4fa0..9306bfa1 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java +++ b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java @@ -1356,8 +1356,8 @@ public class XmppConnection implements Runnable { interrupt(); Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": disconnecting force="+Boolean.valueOf(force)); if (force) { + tagWriter.forceClose(); forceCloseSocket(); - return; } else { if (tagWriter.isActive()) { tagWriter.finish(); |