Don’t call Optional.get() on potentially non-existing instance.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sat, 26 Jan 2013 10:41:18 +0000 (11:41 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sat, 26 Jan 2013 10:41:18 +0000 (11:41 +0100)
src/main/java/net/pterodactylus/sone/web/ViewPostPage.java

index 50719ee..8adf46d 100644 (file)
@@ -75,7 +75,7 @@ public class ViewPostPage extends SoneTemplatePage {
                String postId = request.getHttpRequest().getParam("post");
                boolean raw = request.getHttpRequest().getParam("raw").equals("true");
                Optional<Post> post = webInterface.getCore().getPost(postId);
-               templateContext.set("post", post.get());
+               templateContext.set("post", post.orNull());
                templateContext.set("raw", raw);
        }