From c143f0de2596f3c223f04315f81cf647effeca3f Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Fri, 17 Jan 2014 10:40:10 +0000 Subject: [PATCH] SMACK-525 fix NPE when initConnection() fails git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/branches/smack_3_4_0@13862 b35dd754-fafc-0310-a699-88a17e54d16e --- source/org/jivesoftware/smack/XMPPConnection.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/source/org/jivesoftware/smack/XMPPConnection.java b/source/org/jivesoftware/smack/XMPPConnection.java index f442e7386..c775e52e4 100644 --- a/source/org/jivesoftware/smack/XMPPConnection.java +++ b/source/org/jivesoftware/smack/XMPPConnection.java @@ -1043,10 +1043,13 @@ public class XMPPConnection extends Connection { */ synchronized void notifyConnectionError(Exception e) { // Listeners were already notified of the exception, return right here. - if (packetReader.done && packetWriter.done) return; + if ((packetReader == null || packetReader.done) && + (packetWriter == null || packetWriter.done)) return; - packetReader.done = true; - packetWriter.done = true; + if (packetReader != null) + packetReader.done = true; + if (packetWriter != null) + packetWriter.done = true; // Closes the connection temporary. A reconnection is possible shutdown(new Presence(Presence.Type.unavailable)); // Notify connection listeners of the error.