diff options
author | Daniel Gultsch <daniel@gultsch.de> | 2016-06-13 19:05:32 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2016-06-14 21:28:02 +0200 |
commit | aaeced4e209812f3a779dc9560105dc8d3218af5 (patch) | |
tree | a3fd01d36839bd3aa542d35b239e8f1dcbd96bd8 /src/main/java/eu/siacs/conversations/xml/TagWriter.java | |
parent | 3e748bc49a25c2700e6929286f7041e9c571d7f3 (diff) |
make sure tagwriter is clear before force closing socket
Diffstat (limited to 'src/main/java/eu/siacs/conversations/xml/TagWriter.java')
-rw-r--r-- | src/main/java/eu/siacs/conversations/xml/TagWriter.java | 26 |
1 files changed, 8 insertions, 18 deletions
diff --git a/src/main/java/eu/siacs/conversations/xml/TagWriter.java b/src/main/java/eu/siacs/conversations/xml/TagWriter.java index f11c18464..9d16c338c 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; + } } |