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
This commit is contained in:
Florian Schmaus 2014-01-17 10:40:10 +00:00 committed by flow
parent f155cb4d07
commit c143f0de25
1 changed files with 6 additions and 3 deletions

View File

@ -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.