aboutsummaryrefslogtreecommitdiff
path: root/juick-xmpp/src/main/java/com
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-01-17 13:33:50 +0300
committerGravatar Vitaly Takmazov2018-01-17 13:33:50 +0300
commit62df283157ff32dded77e833fbd0f4e3007acbbe (patch)
tree8e213bcc99b4f1679ba0d03ce6eef0cf8421156c /juick-xmpp/src/main/java/com
parent34e33eb5202570e8343382df7ca6a2e87385a611 (diff)
prevent nulls with StringUtils.defaultString()
Diffstat (limited to 'juick-xmpp/src/main/java/com')
-rw-r--r--juick-xmpp/src/main/java/com/juick/components/XMPPConnection.java7
-rw-r--r--juick-xmpp/src/main/java/com/juick/xmpp/extensions/JuickMessage.java3
2 files changed, 6 insertions, 4 deletions
diff --git a/juick-xmpp/src/main/java/com/juick/components/XMPPConnection.java b/juick-xmpp/src/main/java/com/juick/components/XMPPConnection.java
index edf2d0f3..b515ac1c 100644
--- a/juick-xmpp/src/main/java/com/juick/components/XMPPConnection.java
+++ b/juick-xmpp/src/main/java/com/juick/components/XMPPConnection.java
@@ -27,6 +27,7 @@ import com.juick.service.UserService;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
@@ -292,7 +293,7 @@ public class XMPPConnection implements AutoCloseable {
if (attachment != null) {
txt += attachment.getMedium().getUrl() + "\n";
}
- txt += jmsg.getText() + "\n\n";
+ txt += StringUtils.defaultString(jmsg.getText()) + "\n\n";
txt += "#" + jmsg.getMid() + " http://juick.com/" + jmsg.getMid();
Nickname nick = new Nickname("@" + jmsg.getUser().getName());
@@ -335,7 +336,7 @@ public class XMPPConnection implements AutoCloseable {
if (attachment != null) {
txt += attachment.getMedium().getUrl() + "\n";
}
- txt += jmsg.getText() + "\n\n" + "#" + jmsg.getMid() + "/" + jmsg.getRid() + " http://juick.com/" + jmsg.getMid() + "#" + jmsg.getRid();
+ txt += StringUtils.defaultString(jmsg.getText()) + "\n\n" + "#" + jmsg.getMid() + "/" + jmsg.getRid() + " http://juick.com/" + jmsg.getMid() + "#" + jmsg.getRid();
Message msg = new Message();
msg.setFrom(bot.getJid());
@@ -362,7 +363,7 @@ public class XMPPConnection implements AutoCloseable {
if (attachment != null) {
txt += attachment.getMedium().getUrl() + "\n";
}
- txt += jmsg.getText() + "\n\n";
+ txt += StringUtils.defaultString(jmsg.getText()) + "\n\n";
txt += "#" + jmsg.getMid();
if (jmsg.getReplies() > 0) {
if (jmsg.getReplies() % 10 == 1 && jmsg.getReplies() % 100 != 11) {
diff --git a/juick-xmpp/src/main/java/com/juick/xmpp/extensions/JuickMessage.java b/juick-xmpp/src/main/java/com/juick/xmpp/extensions/JuickMessage.java
index 86b4d02e..c28eee14 100644
--- a/juick-xmpp/src/main/java/com/juick/xmpp/extensions/JuickMessage.java
+++ b/juick-xmpp/src/main/java/com/juick/xmpp/extensions/JuickMessage.java
@@ -20,6 +20,7 @@ package com.juick.xmpp.extensions;
import com.juick.Tag;
import com.juick.xmpp.StanzaChild;
import com.juick.xmpp.utils.XmlUtils;
+import org.apache.commons.lang3.StringUtils;
import org.apache.commons.text.StringEscapeUtils;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
@@ -120,7 +121,7 @@ public class JuickMessage extends com.juick.Message implements StanzaChild {
ret.append(JuickUser.toString(getUser()));
}
if (getText() != null) {
- ret.append("<body>").append(StringEscapeUtils.escapeXml10(getText())).append("</body>");
+ ret.append("<body>").append(StringEscapeUtils.escapeXml10(StringUtils.defaultString(getText()))).append("</body>");
}
for (Tag Tag : getTags()) {
ret.append("<tag>").append(StringEscapeUtils.escapeXml10(Tag.getName())).append("</tag>");