From 70e12fd3ae5acff295f6862245acc73fde2bc532 Mon Sep 17 00:00:00 2001 From: VilenEera Date: Thu, 2 Nov 2017 15:27:49 +0800 Subject: [PATCH] bugfix : if current user not logged in,get comments return 500 Internal Server Error --- src/main/java/io/spring/application/CommentQueryService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/io/spring/application/CommentQueryService.java b/src/main/java/io/spring/application/CommentQueryService.java index 332a467..f400b53 100644 --- a/src/main/java/io/spring/application/CommentQueryService.java +++ b/src/main/java/io/spring/application/CommentQueryService.java @@ -36,7 +36,7 @@ public class CommentQueryService { public List findByArticleId(String articleId, User user) { List comments = commentReadService.findByArticleId(articleId); - if (comments.size() > 0) { + if (comments.size() > 0 && user != null) { Set followingAuthors = userRelationshipQueryService.followingAuthors(user.getId(), comments.stream().map(commentData -> commentData.getProfileData().getId()).collect(Collectors.toList())); comments.forEach(commentData -> { if (followingAuthors.contains(commentData.getProfileData().getId())) {