mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-05-11 13:17:29 +08:00
Merge pull request #157 from nagisa77/codex/fix-nullpointerexception-in-usercontrollertest
Fix null content handling in UserController
This commit is contained in:
@@ -175,11 +175,14 @@ public class UserController {
|
|||||||
PostMetaDto dto = new PostMetaDto();
|
PostMetaDto dto = new PostMetaDto();
|
||||||
dto.setId(post.getId());
|
dto.setId(post.getId());
|
||||||
dto.setTitle(post.getTitle());
|
dto.setTitle(post.getTitle());
|
||||||
|
String content = post.getContent();
|
||||||
|
if (content == null) {
|
||||||
|
content = "";
|
||||||
|
}
|
||||||
if (snippetLength >= 0) {
|
if (snippetLength >= 0) {
|
||||||
String c = post.getContent();
|
dto.setSnippet(content.length() > snippetLength ? content.substring(0, snippetLength) : content);
|
||||||
dto.setSnippet(c.length() > snippetLength ? c.substring(0, snippetLength) : c);
|
|
||||||
} else {
|
} else {
|
||||||
dto.setSnippet(post.getContent());
|
dto.setSnippet(content);
|
||||||
}
|
}
|
||||||
dto.setCreatedAt(post.getCreatedAt());
|
dto.setCreatedAt(post.getCreatedAt());
|
||||||
dto.setCategory(post.getCategory().getName());
|
dto.setCategory(post.getCategory().getName());
|
||||||
|
|||||||
Reference in New Issue
Block a user