From d9cc4e7060e81a583016b7b69203ab397f3d3478 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Wed, 13 Jun 2018 11:58:48 +0300 Subject: fix processing message with empty * tag --- .../src/main/java/com/juick/service/TagServiceImpl.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'juick-server-jdbc/src/main') 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 fromString(final String txt) { String firstLine = txt.split("\\n", 2)[0]; - List 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()); } -- cgit v1.2.3