diff options
author | 2018-01-17 13:33:50 +0300 | |
---|---|---|
committer | 2018-01-17 13:33:50 +0300 | |
commit | 62df283157ff32dded77e833fbd0f4e3007acbbe (patch) | |
tree | 8e213bcc99b4f1679ba0d03ce6eef0cf8421156c /juick-www/src/main/java/com/mitchellbosecke/pebble/extension/filters/FormatMessageFilter.java | |
parent | 34e33eb5202570e8343382df7ca6a2e87385a611 (diff) |
prevent nulls with StringUtils.defaultString()
Diffstat (limited to 'juick-www/src/main/java/com/mitchellbosecke/pebble/extension/filters/FormatMessageFilter.java')
-rw-r--r-- | juick-www/src/main/java/com/mitchellbosecke/pebble/extension/filters/FormatMessageFilter.java | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/juick-www/src/main/java/com/mitchellbosecke/pebble/extension/filters/FormatMessageFilter.java b/juick-www/src/main/java/com/mitchellbosecke/pebble/extension/filters/FormatMessageFilter.java index d127daa9..b492f121 100644 --- a/juick-www/src/main/java/com/mitchellbosecke/pebble/extension/filters/FormatMessageFilter.java +++ b/juick-www/src/main/java/com/mitchellbosecke/pebble/extension/filters/FormatMessageFilter.java @@ -21,6 +21,7 @@ import com.juick.Message; import com.juick.util.MessageUtils; import com.mitchellbosecke.pebble.extension.Filter; import com.mitchellbosecke.pebble.extension.escaper.SafeString; +import org.apache.commons.lang3.StringUtils; import java.util.List; import java.util.Map; @@ -34,8 +35,8 @@ public class FormatMessageFilter implements Filter { if (input instanceof Message) { Message msg = (Message) input; boolean isCode = msg.getTags().stream().anyMatch(t -> t.getName().equals("code")); - String formattedMessage = isCode ? MessageUtils.formatMessageCode(msg.getText()) - : MessageUtils.formatMessage(msg.getText()); + String formattedMessage = isCode ? MessageUtils.formatMessageCode(StringUtils.defaultString(msg.getText())) + : MessageUtils.formatMessage(StringUtils.defaultString(msg.getText())); return new SafeString(formattedMessage); } throw new IllegalArgumentException("invalid input"); |