From 2094af6d10b01e1c5faa1a597db1e0118c1e3dc3 Mon Sep 17 00:00:00 2001 From: LIlGG <1103069291@qq.com> Date: Mon, 22 Jul 2024 16:14:09 +0800 Subject: [PATCH] fix: solve the problem that tag may be an error when it is empty --- src/main/java/run/halo/moments/search/DocumentConverter.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/run/halo/moments/search/DocumentConverter.java b/src/main/java/run/halo/moments/search/DocumentConverter.java index 88fd70e..4f475ad 100644 --- a/src/main/java/run/halo/moments/search/DocumentConverter.java +++ b/src/main/java/run/halo/moments/search/DocumentConverter.java @@ -5,6 +5,7 @@ import java.time.ZoneId; import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; +import java.util.Optional; import lombok.NonNull; import lombok.RequiredArgsConstructor; import org.springframework.core.convert.converter.Converter; @@ -41,7 +42,8 @@ public Mono convert(Moment moment) { haloDoc.setDescription(momentContent.getHtml()); haloDoc.setExposed(isExposed(moment)); haloDoc.setContent(momentContent.getHtml()); - haloDoc.setTags(moment.getSpec().getTags().stream().toList()); + var tags = moment.getSpec().getTags(); + Optional.ofNullable(tags).ifPresent((tag) -> haloDoc.setTags(tag.stream().toList())); haloDoc.setOwnerName(moment.getSpec().getOwner()); haloDoc.setUpdateTimestamp(moment.getSpec().getReleaseTime()); haloDoc.setCreationTimestamp(moment.getMetadata().getCreationTimestamp());