From 018cba7f4f27adbe10f1c6cc7063edb62615f20b Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Mon, 15 Jun 2020 17:52:28 +0200 Subject: [PATCH] [tcp] Log XmlStringBuilder NPEs and the causing class --- .../java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java b/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java index ded929681..c5328798a 100644 --- a/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java +++ b/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java @@ -1318,7 +1318,12 @@ public class XMPPTCPConnection extends AbstractXMPPConnection { CharSequence elementXml = element.toXML(outgoingStreamXmlEnvironment); if (elementXml instanceof XmlStringBuilder) { - ((XmlStringBuilder) elementXml).write(writer, outgoingStreamXmlEnvironment); + try { + ((XmlStringBuilder) elementXml).write(writer, outgoingStreamXmlEnvironment); + } catch (NullPointerException npe) { + LOGGER.log(Level.FINE, "NPE in XmlStringBuilder of " + element.getClass() + ": " + element, npe); + throw npe; + } } else { writer.write(elementXml.toString());