From c69ad8f52ca6c24d02f4458ab0d54aad5f918505 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Fri, 17 Feb 2017 10:26:42 +0100 Subject: [PATCH] npe checks --- .../siacs/conversations/services/XmppConnectionService.java | 5 ++++- .../java/eu/siacs/conversations/xmpp/XmppConnection.java | 6 ++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java index 81adc00c3..009d71d9f 100644 --- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java @@ -3088,7 +3088,10 @@ public class XmppConnectionService extends Service { disconnect(account, force || account.getTrueStatus().isError() || !hasInternet); account.getRoster().clearPresences(); connection.resetEverything(); - account.getAxolotlService().resetBrokenness(); + final AxolotlService axolotlService = account.getAxolotlService(); + if (axolotlService != null) { + axolotlService.resetBrokenness(); + } if (!hasInternet) { account.setStatus(Account.State.NO_INTERNET); } diff --git a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java index 192fa8c5a..b5bc0fa0d 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java +++ b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java @@ -100,7 +100,7 @@ public class XmppConnection implements Runnable { private final WakeLock wakeLock; private Socket socket; private XmlReader tagReader; - private TagWriter tagWriter; + private TagWriter tagWriter = new TagWriter(); private final Features features = new Features(this); private boolean needsBinding = true; private boolean shouldAuthenticate = true; @@ -449,7 +449,9 @@ public class XmppConnection implements Runnable { } this.socket = socket; tagReader = new XmlReader(wakeLock); - if (tagWriter != null) tagWriter.forceClose(); + if (tagWriter != null) { + tagWriter.forceClose(); + } tagWriter = new TagWriter(); tagWriter.setOutputStream(socket.getOutputStream()); tagReader.setInputStream(socket.getInputStream());