diff options
Diffstat (limited to 'juick-ws')
-rw-r--r-- | juick-ws/src/main/java/com/juick/ws/XMPPConnection.java | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/juick-ws/src/main/java/com/juick/ws/XMPPConnection.java b/juick-ws/src/main/java/com/juick/ws/XMPPConnection.java index 1f1e07c7..7a01c501 100644 --- a/juick-ws/src/main/java/com/juick/ws/XMPPConnection.java +++ b/juick-ws/src/main/java/com/juick/ws/XMPPConnection.java @@ -19,10 +19,12 @@ import rocks.xmpp.core.session.XmppSessionConfiguration; import rocks.xmpp.core.session.debug.LogbackDebugger; import rocks.xmpp.core.stanza.model.Message; import rocks.xmpp.extensions.component.accept.ExternalComponent; +import rocks.xmpp.util.XmppUtils; import javax.inject.Inject; import javax.xml.bind.JAXBException; -import javax.xml.bind.Marshaller; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamWriter; import java.io.IOException; import java.io.StringWriter; import java.util.List; @@ -75,10 +77,18 @@ public class XMPPConnection implements AutoCloseable { com.juick.Message jmsg = msg.getExtension(com.juick.Message.class); if (jmsg != null) { if (logger.isInfoEnabled()) { // prevent writeValueAsString execution if log is disabled - Marshaller marshaller = xmpp.createMarshaller(); - StringWriter stanzaWriter = new StringWriter(); - marshaller.marshal(msg, stanzaWriter); - logger.info("got msg: {}", stanzaWriter.toString()); + try { + StringWriter stanzaWriter = new StringWriter(); + XMLStreamWriter xmppStreamWriter = XmppUtils.createXmppStreamWriter( + xmpp.getConfiguration().getXmlOutputFactory().createXMLStreamWriter(stanzaWriter)); + xmpp.createMarshaller().marshal(msg, xmppStreamWriter); + xmppStreamWriter.flush(); + xmppStreamWriter.close(); + logger.info("got msg: {}", stanzaWriter.toString()); + } catch (XMLStreamException e1) { + logger.info("jaxb exception", e1); + } + } if (jmsg.getMid() == 0) { int uid_to = NumberUtils.toInt(msg.getTo().getLocal(), 0); |