]> source.dussan.org Git - gitblit.git/commitdiff
Fix possible NPE in RawServlet 37/137/1
authorJames Moger <james.moger@gitblit.com>
Sat, 5 Jul 2014 16:27:17 +0000 (12:27 -0400)
committerJames Moger <james.moger@gitblit.com>
Sat, 5 Jul 2014 16:27:17 +0000 (12:27 -0400)
src/main/java/com/gitblit/servlet/RawServlet.java

index 15e036ea30e61f7cacfb48c6ad2f7f55999c7d04..e0f064c35698c943d9d8a7e424dc3c53ce32a634 100644 (file)
@@ -254,6 +254,15 @@ public class RawServlet extends DaggerServlet {
                                                // load, interpret, and serve text content as UTF-8
                                                String [] encodings = runtimeManager.getSettings().getStrings(Keys.web.blobEncodings).toArray(new String[0]);
                                                String content = JGitUtils.getStringContent(r, commit.getTree(), requestedPath, encodings);
+                                               if (content == null) {
+                                                       logger.error("RawServlet Failed to load {} {} {}", repository, commit.getName(), path);
+                                                       String str = MessageFormat.format(
+                                                                       "# Error\nSorry, the requested resource **{0}** was not found.",
+                                                                       requestedPath);
+                                                       response.setStatus(HttpServletResponse.SC_NOT_FOUND);
+                                                       error(response, str);
+                                                       return;
+                                               }
 
                                                byte [] bytes = content.getBytes(Constants.ENCODING);
                                                response.setContentLength(bytes.length);