From 32522d67e66c2d9adb2fb4d199b9e82172b95bf8 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Mon, 2 Apr 2018 19:44:30 +0300 Subject: XMPP: fix NPE --- juick-server-xmpp/src/main/java/com/juick/server/XMPPConnection.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/juick-server-xmpp/src/main/java/com/juick/server/XMPPConnection.java b/juick-server-xmpp/src/main/java/com/juick/server/XMPPConnection.java index a60b506d..fbf1a529 100644 --- a/juick-server-xmpp/src/main/java/com/juick/server/XMPPConnection.java +++ b/juick-server-xmpp/src/main/java/com/juick/server/XMPPConnection.java @@ -624,8 +624,9 @@ public class XMPPConnection implements StanzaListener, NotificationListener { incomingMessageJuick(user_from, msg.getFrom(), msg.getBody().trim(), null); } } catch (Exception e) { - return; + logger.info("xmpp exception", e); } + return; } int uid_to = userService.getUIDbyName(username); @@ -680,7 +681,7 @@ public class XMPPConnection implements StanzaListener, NotificationListener { // new message List tags = tagService.fromString(command, false); String body = command.substring(TagUtils.toString(tags).length()); - String attachmentType = StringUtils.isNotEmpty(attachment.toString()) ? attachment.toString().substring(attachment.toString().length() - 3) : null; + String attachmentType = attachment != null && StringUtils.isNotEmpty(attachment.toString()) ? attachment.toString().substring(attachment.toString().length() - 3) : null; int mid = messagesService.createMessage(user_from.getUid(), body, attachmentType, tags); subscriptionService.subscribeMessage(mid, user_from.getUid()); if (StringUtils.isNotEmpty(attachmentType)) { -- cgit v1.2.3