aboutsummaryrefslogtreecommitdiff
path: root/juick-www/src/main/java/com
diff options
context:
space:
mode:
Diffstat (limited to 'juick-www/src/main/java/com')
-rw-r--r--juick-www/src/main/java/com/juick/www/controllers/UserThread.java14
1 files changed, 14 insertions, 0 deletions
diff --git a/juick-www/src/main/java/com/juick/www/controllers/UserThread.java b/juick-www/src/main/java/com/juick/www/controllers/UserThread.java
index 4020e149..5765e02d 100644
--- a/juick-www/src/main/java/com/juick/www/controllers/UserThread.java
+++ b/juick-www/src/main/java/com/juick/www/controllers/UserThread.java
@@ -19,12 +19,16 @@ package com.juick.www.controllers;
import com.juick.Message;
import com.juick.server.helpers.TagStats;
+import com.juick.server.util.HttpNotFoundException;
import com.juick.service.MessagesService;
import com.juick.service.TagService;
import com.juick.service.UserService;
import com.juick.util.MessageUtils;
import com.juick.www.WebApp;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@@ -68,6 +72,10 @@ public class UserThread {
com.juick.Message msg = messagesService.getMessage(mid);
+ if (msg == null) {
+ throw new HttpNotFoundException();
+ }
+
boolean listview = false;
String paramView = request.getParameter("view");
if (paramView != null) {
@@ -108,6 +116,12 @@ public class UserThread {
}
}
+ // when message id is not fit to int
+ @ExceptionHandler(NumberFormatException.class)
+ public ResponseEntity<String> notfound() {
+ return new ResponseEntity<>(HttpStatus.NOT_FOUND);
+ }
+
public com.juick.Message printMessage(PrintWriter out, com.juick.Message msg, com.juick.User visitor) {
msg.VisitorCanComment = visitor.getUid() > 0;