diff options
author | Vitaly Takmazov | 2018-06-13 11:58:48 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2018-06-13 11:58:48 +0300 |
commit | d9cc4e7060e81a583016b7b69203ab397f3d3478 (patch) | |
tree | d129d44e953b1b083aef0ca376c53d1f106b1dad /juick-server-jdbc/src/main/java/com/juick | |
parent | 47fca902ee7b11a4bead5fefc34fcc5be0550436 (diff) |
fix processing message with empty * tag
Diffstat (limited to 'juick-server-jdbc/src/main/java/com/juick')
-rw-r--r-- | juick-server-jdbc/src/main/java/com/juick/service/TagServiceImpl.java | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/juick-server-jdbc/src/main/java/com/juick/service/TagServiceImpl.java b/juick-server-jdbc/src/main/java/com/juick/service/TagServiceImpl.java index d7800390..524ad32d 100644 --- a/juick-server-jdbc/src/main/java/com/juick/service/TagServiceImpl.java +++ b/juick-server-jdbc/src/main/java/com/juick/service/TagServiceImpl.java @@ -20,6 +20,7 @@ package com.juick.service; import com.juick.Tag; import com.juick.User; import com.juick.server.helpers.TagStats; +import com.juick.util.StreamUtils; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.jdbc.core.RowMapper; @@ -210,10 +211,9 @@ public class TagServiceImpl extends BaseJdbcService implements TagService { @Override public List<Tag> fromString(final String txt) { String firstLine = txt.split("\\n", 2)[0]; - List<String> firstWords = Arrays.asList(firstLine.split("\\ ")); - int nonTagIndex = IntStream.range(0, firstWords.size()) - .filter(i -> !firstWords.get(i).startsWith("*")).findFirst().orElse(firstWords.size()); - return firstWords.subList(0, nonTagIndex).stream().map(t -> getTag(t.substring(1), true)) + return StreamUtils.takeWhile(Arrays.stream(firstLine.split("\\ ")), + t -> !t.equals("*") && t.startsWith("*")) + .map(t -> getTag(t.substring(1), true)) .collect(Collectors.toList()); } |